# SelectedDatesCollection

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/primitives/struct-selecteddatescollection/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct SelectedDatesCollection
```

Represents a set of selected dates in a [`Calendar`](/docs/0.5.0/api/ferroui-controls/struct-calendar/).

The value is a shared handle: clones refer to the same collection, and
handles compare by identity. Every change goes through the collection,
which validates it against the selection mode of the calendar that owns
it and keeps the selected date of that calendar in step.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L26)

## Members

- [`new`](#function-new)
- [`add_range`](#function-add_range)
- [`count`](#function-count)
- [`is_empty`](#function-is_empty)
- [`get`](#function-get)
- [`to_vec`](#function-to_vec)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`add`](#function-add)
- [`insert`](#function-insert)
- [`remove`](#function-remove)
- [`remove_at`](#function-remove_at)
- [`set`](#function-set)
- [`clear`](#function-clear)
- [`move_item`](#function-move_item)
- [`add_collection_changed`](#function-add_collection_changed)
- [`remove_collection_changed`](#function-remove_collection_changed)

<a id="function-new"></a>

### new

```rust
fn new(owner: &Ref<Calendar>) -> Self
```

Initializes a new instance of the `SelectedDatesCollection` class.

`owner` is the `Calendar` associated with this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L55)

<a id="function-add_range"></a>

### add_range

```rust
fn add_range(self: &Self, start: DateTime, end: DateTime)
```

Adds all the dates in the specified range, which includes the first
and last dates, to the collection.

`start` is the first date to add to the collection and `end` the
last one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L82)

<a id="function-count"></a>

### count

```rust
fn count(self: &Self) -> usize
```

The number of dates in the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L153)

<a id="function-is_empty"></a>

### is_empty

```rust
fn is_empty(self: &Self) -> bool
```

Whether the collection has no dates.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L158)

<a id="function-get"></a>

### get

```rust
fn get(self: &Self, index: usize) -> DateTime
```

The date at `index`. Panics when the index is out of range.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L163)

<a id="function-to_vec"></a>

### to_vec

```rust
fn to_vec(self: &Self) -> Vec<DateTime>
```

The dates of the collection, as they are now.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L168)

<a id="function-contains"></a>

### contains

```rust
fn contains(self: &Self, item: DateTime) -> bool
```

Whether the collection contains the date.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L173)

<a id="function-index_of"></a>

### index_of

```rust
fn index_of(self: &Self, item: DateTime) -> Option<usize>
```

The index of the date in the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L178)

<a id="function-add"></a>

### add

```rust
fn add(self: &Self, item: DateTime)
```

Adds a date to the end of the collection.

Panics when the selection mode of the calendar does not allow the
change or the date cannot be selected.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L186)

<a id="function-insert"></a>

### insert

```rust
fn insert(self: &Self, index: usize, item: DateTime)
```

Inserts a date into the collection at the specified index.

Panics when the selection mode of the calendar does not allow the
change or the date cannot be selected.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L194)

<a id="function-remove"></a>

### remove

```rust
fn remove(self: &Self, item: DateTime) -> bool
```

Removes a date from the collection. Returns whether it was present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L200)

<a id="function-remove_at"></a>

### remove_at

```rust
fn remove_at(self: &Self, index: usize)
```

Removes the date at the specified index of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L211)

<a id="function-set"></a>

### set

```rust
fn set(self: &Self, index: usize, item: DateTime)
```

Replaces the date at the specified index.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L217)

<a id="function-clear"></a>

### clear

```rust
fn clear(self: &Self)
```

Removes all dates from the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L223)

<a id="function-move_item"></a>

### move_item

```rust
fn move_item(self: &Self, old_index: usize, new_index: usize)
```

Moves the date at `old_index` to `new_index`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L228)

<a id="function-add_collection_changed"></a>

### add_collection_changed

```rust
fn add_collection_changed(self: &Self, handler: Rc<CollectionChangedHandler<DateTime>>) -> u64
```

Subscribes to the changes of the collection; returns the token of
the subscription.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L234)

<a id="function-remove_collection_changed"></a>

### remove_collection_changed

```rust
fn remove_collection_changed(self: &Self, token: u64) -> bool
```

Ends a subscription to the changes of the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/calendar/selected_dates_collection.rs#L239)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `PartialEq`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
