# KeyValueCollection

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

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

```rust
struct KeyValueCollection<T, K>
```

The sorted pairs of a key and an item of a sorted change set (`KeyValueCollection<TObject,
TKey>`), with the comparer that sorted them and the reason of the sort.

Deviation (DEVIATIONS.md, DynamicData): a pair is the tuple `(key, item)`, upstream's
`KeyValuePair<TKey, TObject>`; `.0` is `Key` and `.1` is `Value`. The pairs are shared, so
cloning a collection is cheap.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L15)

## Members

- [`new`](#function-new)
- [`empty`](#function-empty)
- [`comparer`](#function-comparer)
- [`count`](#function-count)
- [`optimisations`](#function-optimisations)
- [`sort_reason`](#function-sort_reason)
- [`items`](#function-items)
- [`to_vec`](#function-to_vec)
- [`values`](#function-values)
- [`keys`](#function-keys)
- [`ptr_eq`](#function-ptr_eq)

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

### new

```rust
fn new(items: Vec<(K, T)>, comparer: KeyValueComparer<T, K>, sort_reason: SortReason, optimisations: SortOptimisations) -> Self
```

A collection of `items`, sorted by `comparer` for `sort_reason`
(`KeyValueCollection(IReadOnlyCollection<KeyValuePair<TKey, TObject>>, IComparer, SortReason,
SortOptimisations)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L39)

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

### empty

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

An empty collection (`KeyValueCollection()`): no optimisations, compared by the keys.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L44)

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

### comparer

```rust
fn comparer(self: &Self) -> &KeyValueComparer<T, K>
```

The comparer of the pairs (`Comparer`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L49)

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

### count

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

The number of pairs (`Count`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L54)

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

### optimisations

```rust
fn optimisations(self: &Self) -> SortOptimisations
```

The optimisations of the sort (`Optimisations`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L59)

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

### sort_reason

```rust
fn sort_reason(self: &Self) -> SortReason
```

The reason of the sort (`SortReason`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L64)

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

### items

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

The pairs, in order.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L69)

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

### to_vec

```rust
fn to_vec(self: &Self) -> Vec<(K, T)>
where T: Clone,
      K: Clone
```

The pairs as a list of their own (`ToList`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L74)

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

### values

```rust
fn values(self: &Self) -> impl Iterator<Item = &T>
```

The items, in order (`Select(kv => kv.Value)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L83)

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

### keys

```rust
fn keys(self: &Self) -> impl Iterator<Item = &K>
```

The keys, in order (`Select(kv => kv.Key)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L88)

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

### ptr_eq

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

Whether `self` and `other` share their pairs (`ReferenceEquals` of upstream's collections).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_collection.rs#L93)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- `Clone`
- `Default`
- `Deref`
- `IntoIterator`
- `PartialEq`
- `Debug`
- [`IKeyValueCollection<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-ikeyvaluecollection/)

## Availability

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