# SlotOrderMap

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/collections/generic/struct-slotordermap/

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

```rust
struct SlotOrderMap<K, V>
```

A map from keys to values that enumerates its entries in the order of the slots of .NET's
`Dictionary<TKey, TValue>`: in the order they were added, except that an entry added after a
removal takes the slot of the entry removed last (the free list of .NET), and `clear` starts
over.

Code ported from .NET that enumerates a dictionary (its keys, values, or a `Select` over it)
produces the same sequence with this type. `HashMap` gives an arbitrary order, and
`indexmap::IndexMap` the order of addition, which differs from this one after a removal (with
`shift_remove` and with `swap_remove`): use `HashMap` where nothing enumerates the map,
`IndexMap` where the order of addition is what is observed, and this type only where the exact
.NET sequence after removals is (the caches of DynamicData, whose change sets list their items
in it).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L22)

## Members

- [`iter`](#function-iter)
- [`iter_mut`](#function-iter_mut)
- [`keys`](#function-keys)
- [`values`](#function-values)
- [`new`](#function-new)
- [`with_capacity`](#function-with_capacity)
- [`len`](#function-len)
- [`is_empty`](#function-is_empty)
- [`contains_key`](#function-contains_key)
- [`get`](#function-get)
- [`get_mut`](#function-get_mut)
- [`insert`](#function-insert)
- [`try_add`](#function-try_add)
- [`add`](#function-add)
- [`remove`](#function-remove)
- [`clear`](#function-clear)

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

### iter

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

The entries in the order of enumeration.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L45)

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

### iter_mut

```rust
fn iter_mut(self: &mut Self) -> impl Iterator<Item = (&K, &mut V)>
```

The entries in the order of enumeration, with their values to change.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L50)

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

### keys

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

The keys in the order of enumeration (`Keys`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L55)

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

### values

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

The values in the order of enumeration (`Values`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L60)

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

### new

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

An empty map.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L67)

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

### with_capacity

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

An empty map with room for `capacity` entries.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L72)

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

### len

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

The number of entries (`Count`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L77)

<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.System/collections/generic/slot_order_map.rs#L81)

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

### contains_key

```rust
fn contains_key<Q: Hash + Eq + ?Sized>(self: &Self, key: &Q) -> bool
where K: Borrow<Q>
```

Whether the map has `key` (`ContainsKey`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L86)

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

### get

```rust
fn get<Q: Hash + Eq + ?Sized>(self: &Self, key: &Q) -> Option<&V>
where K: Borrow<Q>
```

The value of `key` (`TryGetValue`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L94)

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

### get_mut

```rust
fn get_mut<Q: Hash + Eq + ?Sized>(self: &mut Self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>
```

The value of `key`, to change.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L103)

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

### insert

```rust
fn insert(self: &mut Self, key: K, value: V) -> Option<V>
```

Sets the value of `key` (the indexer's setter, `this[key] = value`): an existing entry keeps
its place; the previous value is returned.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L113)

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

### try_add

```rust
fn try_add(self: &mut Self, key: K, value: V) -> bool
```

Adds an entry unless the key is there already (`TryAdd`); false when it is.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L133)

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

### add

```rust
fn add(self: &mut Self, key: K, value: V)
```

Adds an entry (`Add`).
## Panics
When the key is there already (`ArgumentException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L145)

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

### remove

```rust
fn remove<Q: Hash + Eq + ?Sized>(self: &mut Self, key: &Q) -> Option<V>
where K: Borrow<Q>
```

Removes the entry of `key` and gives its value (`Remove(TKey, out TValue)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L150)

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

### clear

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

Removes every entry (`Clear`); the next entry is the first again.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/collections/generic/slot_order_map.rs#L161)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Clone`
- `Default`
- `Debug`
- `FromIterator<(K, V)>`
- `IntoIterator`
- `Extend<(K, V)>`
- `PartialEq`

## Availability

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