# ObservableCollectionExtended

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/binding/struct-observablecollectionextended/

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

```rust
struct ObservableCollectionExtended<T>
```

An observable collection with ranges, loads and suspended notifications
(`ObservableCollectionExtended<T>`), the collection that the binding operators fill.

It is a shared handle over an `ObservableCollection<T>` (the base class upstream), which items
controls read and observe: `collection` is that collection. The changes made
through this handle raise the notifications of the base, except those that are suspended
(upstream's overrides of `OnCollectionChanged` and `OnPropertyChanged`).

Deviation (DEVIATIONS.md, DynamicData): a subclass of .NET intercepts the notifications of every
change; here the changes made through `collection` directly are not
suspended.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L38)

## Members

- [`new`](#function-new)
- [`with_capacity`](#function-with_capacity)
- [`from_items`](#function-from_items)
- [`collection`](#function-collection)
- [`ptr_eq`](#function-ptr_eq)
- [`add_collection_changed`](#function-add_collection_changed)
- [`remove_collection_changed`](#function-remove_collection_changed)
- [`count`](#function-count)
- [`is_empty`](#function-is_empty)
- [`get`](#function-get)
- [`items`](#function-items)
- [`to_vec`](#function-to_vec)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`add`](#function-add)
- [`insert`](#function-insert)
- [`set`](#function-set)
- [`remove_at`](#function-remove_at)
- [`remove`](#function-remove)
- [`move_item`](#function-move_item)
- [`clear`](#function-clear)
- [`add_range`](#function-add_range)
- [`insert_range`](#function-insert_range)
- [`load`](#function-load)
- [`remove_range`](#function-remove_range)
- [`suspend_count`](#function-suspend_count)
- [`suspend_notifications`](#function-suspend_notifications)
- [`on_property_changed`](#function-on_property_changed)
- [`on_collection_changed`](#function-on_collection_changed)

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

### new

```rust
fn new() -> Self
```

An empty collection (`ObservableCollectionExtended()`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L70)

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

### with_capacity

```rust
fn with_capacity(capacity: usize) -> Self
```

An empty collection that has room for `capacity` items (`ObservableCollectionExtended(new
List<T>(capacity))`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L76)

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

### from_items

```rust
fn from_items(items: Vec<T>) -> Self
```

A collection of the items (`ObservableCollectionExtended(IEnumerable<T>)`,
`ObservableCollectionExtended(List<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L82)

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

### collection

```rust
fn collection(self: &Self) -> &ObservableCollection<T>
```

The observable collection of the items (the base class upstream).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L90)

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

### ptr_eq

```rust
fn ptr_eq(self: &Self, other: &Self) -> bool
```

Whether `self` and `other` are the same collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L95)

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

### add_collection_changed

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

Adds a handler of the typed change notifications; returns the token that removes it
(`CollectionChanged +=`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L101)

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

### remove_collection_changed

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

Removes a handler (`CollectionChanged -=`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L106)

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

### count

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

The number of items (`Count`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L111)

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

### is_empty

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L115)

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

### get

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

The item at `index` (the indexer's getter).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L120)

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

### items

```rust
fn items(self: &Self) -> Ref<'_, Vec<T>>
```

The items, borrowed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L125)

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

### to_vec

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

A copy of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L130)

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

### contains

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

Whether the collection has `item` (`Contains`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L135)

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

### index_of

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

The index of `item` (`IndexOf`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L140)

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

### add

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

Adds an item at the end (`Add`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L145)

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

### insert

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

Inserts an item (`InsertItem`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L151)

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

### set

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

Replaces the item at `index` (the indexer's setter, `SetItem`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L160)

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

### remove_at

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

Removes the item at `index` (`RemoveItem`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L168)

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

### remove

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

Removes `item`; false when it is not there (`Remove`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L177)

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

### move_item

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

Moves the item at `old_index` to `new_index` (`Move`, `MoveItem`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L188)

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

### clear

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

Removes every item (`ClearItems`): a reset.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L201)

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

### add_range

```rust
fn add_range(self: &Self, items: impl IntoIterator<Item = T>)
```

Adds the items at the end, one at a time (`AddRange`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L210)

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

### insert_range

```rust
fn insert_range(self: &Self, items: impl IntoIterator<Item = T>, index: usize)
```

Inserts the items from `index`, one at a time (`InsertRange`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L217)

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

### load

```rust
fn load(self: &Self, items: impl IntoIterator<Item = T>)
```

Clears the collection and adds the items (`Load`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L224)

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

### remove_range

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

Removes `count` items from `index`, one at a time (`RemoveRange`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L233)

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

### suspend_count

```rust
fn suspend_count(self: &Self) -> Rc<dyn IDisposable>
```

Holds back the notifications of `Count` until the handle is disposed, which raises `Count`
once if it changed (`SuspendCount`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L241)

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

### suspend_notifications

```rust
fn suspend_notifications(self: &Self) -> Rc<dyn IDisposable>
```

Holds back the notifications of changes and of `Count` until the handle is disposed, which
raises `Count` and a reset (`SuspendNotifications`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L255)

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

### on_property_changed

```rust
fn on_property_changed(self: &Self, name: &str)
```

Raises `PropertyChanged`, unless it is `Count` and the count is suspended
(`OnPropertyChanged`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L269)

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

### on_collection_changed

```rust
fn on_collection_changed(self: &Self, action: NotifyCollectionChangedAction, new_items: &[T], old_items: &[T], new_starting_index: i32, old_starting_index: i32)
```

Raises `CollectionChanged`, unless the notifications are suspended (`OnCollectionChanged`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_collection_extended.rs#L277)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`ObservableCollectionEx<T>`](/docs/0.5.0/api/ferroui-dynamic-data/binding/trait-observablecollectionex/)
- `Clone`
- `PartialEq`
- `Default`
- `Debug`
- [`INotifyCollectionChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifycollectionchanged/)
- [`INotifyPropertyChanged`](/docs/0.5.0/api/ferroui-base/data/model/use-inotifypropertychanged/)
- [`INotifyCollectionChangedSuspender`](/docs/0.5.0/api/ferroui-dynamic-data/binding/trait-inotifycollectionchangedsuspender/)
- [`IObservableCollection<T>`](/docs/0.5.0/api/ferroui-dynamic-data/binding/trait-iobservablecollection/)
- [`IList<T>`](/docs/0.5.0/api/ferroui-dynamic-data/list/trait-ilist/)
- [`IExtendedList<T>`](/docs/0.5.0/api/ferroui-dynamic-data/list/trait-iextendedlist/)
- `From<&ObservableCollectionExtended<T>>`

## Availability

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