# InlineDictionary

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-inlinedictionary/

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

```rust
struct InlineDictionary<TKey, TValue>
```

A dictionary that holds one entry in place, up to six entries in a small
array and more in a hash map.

The original restricts keys to reference types and compares them by
reference while the dictionary holds its entries in place or in the
array; here keys compare with `==` in every state, which is identity for
the handle types of this crate.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L15)

## Members

- [`new`](#function-new)
- [`add`](#function-add)
- [`set`](#function-set)
- [`get`](#function-get)
- [`remove`](#function-remove)
- [`clear`](#function-clear)
- [`has_entries`](#function-has_entries)
- [`try_get_value`](#function-try_get_value)
- [`get_value_ref_or_null_ref`](#function-get_value_ref_or_null_ref)
- [`get_value_ref_or_add_default`](#function-get_value_ref_or_add_default)
- [`try_get_and_remove_value`](#function-try_get_and_remove_value)
- [`get_and_remove`](#function-get_and_remove)
- [`get_enumerator`](#function-get_enumerator)

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

### new

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L61)

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

### add

```rust
fn add(self: &mut Self, key: TKey, value: TValue)
```

Adds an entry.

Panics when the small array or the dictionary has the key already.
As in the original, a dictionary that holds one entry in place does
not test for it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L162)

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

### set

```rust
fn set(self: &mut Self, key: TKey, value: TValue)
```

Adds an entry or replaces its value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L167)

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

### get

```rust
fn get(self: &Self, key: &TKey) -> &TValue
```

The value of a key (the getter of the indexer).

Panics when the dictionary does not have the key.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L174)

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

### remove

```rust
fn remove(self: &mut Self, key: &TKey) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L181)

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

### clear

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

Removes every entry.

As in the original, the value of an entry that is held in place is
kept and becomes the value of the next key that
`get_value_ref_or_add_default`
adds in place.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L218)

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

### has_entries

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L235)

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

### try_get_value

```rust
fn try_get_value(self: &Self, key: &TKey) -> Option<&TValue>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L239)

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

### get_value_ref_or_null_ref

```rust
fn get_value_ref_or_null_ref(self: &mut Self, key: &TKey) -> Option<&mut TValue>
```

A reference to the value of a key, or `None` (the original's null
reference) when the dictionary does not have the key.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L256)

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

### get_value_ref_or_add_default

```rust
fn get_value_ref_or_add_default(self: &mut Self, key: TKey) -> (&mut TValue, bool)
```

A reference to the value of a key, which is added with the default
value when the dictionary does not have it, and whether it existed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L280)

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

### try_get_and_remove_value

```rust
fn try_get_and_remove_value(self: &mut Self, key: &TKey) -> Option<TValue>
```

Removes an entry and returns its value.

As in the original, an entry of a dictionary that has grown into a
hash map is removed without its value being returned.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L352)

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

### get_and_remove

```rust
fn get_and_remove(self: &mut Self, key: &TKey) -> TValue
```

Removes an entry and returns its value.

Panics when `try_get_and_remove_value`
returns nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L389)

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

### get_enumerator

```rust
fn get_enumerator(self: &Self) -> InlineDictionaryEnumerator<'_, TKey, TValue>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/small_dictionary.rs#L396)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Default`
- `IntoIterator`

## Availability

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