# ChangeAwareList

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

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

```rust
struct ChangeAwareList<T>
```

A list that records its changes until they are captured (`ChangeAwareList<T>`), batching
consecutive insertions and removals into ranges as upstream does.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L34)

## Members

- [`new`](#function-new)
- [`with_capacity`](#function-with_capacity)
- [`from_items`](#function-from_items)
- [`from_list`](#function-from_list)
- [`count`](#function-count)
- [`is_empty`](#function-is_empty)
- [`items`](#function-items)
- [`get`](#function-get)
- [`set`](#function-set)
- [`add`](#function-add)
- [`capture_changes`](#function-capture_changes)
- [`clear`](#function-clear)
- [`contains`](#function-contains)
- [`index_of`](#function-index_of)
- [`index_of_with`](#function-index_of_with)
- [`insert`](#function-insert)
- [`move_item`](#function-move_item)
- [`refresh_with`](#function-refresh_with)
- [`refresh`](#function-refresh)
- [`refresh_at`](#function-refresh_at)
- [`remove`](#function-remove)
- [`remove_at`](#function-remove_at)
- [`add_range`](#function-add_range)
- [`remove_range`](#function-remove_range)

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

### new

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

An empty list (`ChangeAwareList(int capacity = -1)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L48)

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

### with_capacity

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

An empty list with room for `capacity` items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L53)

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

### from_items

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

A list of the items, whose first change adds them (`ChangeAwareList(IEnumerable<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L58)

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

### from_list

```rust
fn from_list(list: &ChangeAwareList<T>, copy_changes: bool) -> Self
```

A copy of `list`, with its changes or without (`ChangeAwareList(ChangeAwareList<T>, bool)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L67)

<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/list/change_aware_list.rs#L76)

<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/list/change_aware_list.rs#L80)

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

### items

```rust
fn items(self: &Self) -> &[T]
```

The items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L85)

<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/list/change_aware_list.rs#L90)

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

### set

```rust
fn set(self: &mut 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/list/change_aware_list.rs#L95)

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

### add

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

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

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

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

### capture_changes

```rust
fn capture_changes(self: &mut Self) -> ChangeSet<T>
```

The changes since the last capture, and a clean slate (`CaptureChanges`): removals that
emptied the list are reported as one `Clear`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L113)

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

### clear

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

Removes every item (`Clear`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L127)

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

### contains

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L139)

<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/list/change_aware_list.rs#L147)

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

### index_of_with

```rust
fn index_of_with(self: &Self, item: &T, comparer: &dyn Fn(&T, &T) -> bool) -> Option<usize>
```

The index of `item` by `comparer` (`IndexOf(T, IEqualityComparer<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L152)

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

### insert

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

Inserts an item (`Insert`).
## Panics
When `index` is beyond the end (`ArgumentException`).

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

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

### move_item

```rust
fn move_item(self: &mut Self, item: &T, destination: usize)
```

Moves `item` to `destination` (`Move(T, int)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L166)

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

### refresh_with

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

Replaces the item at `index` with `item` and reports a refresh (`Refresh(T, int)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L173)

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

### refresh

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

Reports a refresh of `item`; false when it is not in the list (`Refresh(T)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L180)

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

### refresh_at

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

Reports a refresh of the item at `index` (`RefreshAt`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L187)

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

### remove

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

Removes `item`; false when it is not in the list (`Remove(T)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L193)

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

### remove_at

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

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

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

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

### add_range

```rust
fn add_range(self: &mut Self, items: Vec<T>)
```

Adds the items at the end (`AddRange`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L296)

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

### remove_range

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

Removes `count` items from `index` (`RemoveRange`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/list/change_aware_list.rs#L309)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `Default`
- [`IExtendedList<T>`](/docs/0.5.0/api/ferroui-dynamic-data/list/trait-iextendedlist/)
- [`IList<T>`](/docs/0.5.0/api/ferroui-dynamic-data/list/trait-ilist/)

## Availability

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