# FerroPropertyDictionary

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

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

```rust
struct FerroPropertyDictionary<TValue>
```

Stores values with [`FerroProperty`](/docs/0.5.0/api/ferroui-base/struct-ferroproperty/) as key.

This struct is very similar to a sorted list, with the following
differences:
- The key is the id of the property, allowing very fast lookups.
- The entries are stored in one array, which is the only heap allocation.
- It is a plain value: the owner mutates it in place.

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

## Members

- [`new`](#function-new)
- [`new_with_capacity`](#function-new_with_capacity)
- [`count`](#function-count)
- [`get`](#function-get)
- [`set`](#function-set)
- [`get_at`](#function-get_at)
- [`add`](#function-add)
- [`clear`](#function-clear)
- [`contains_key`](#function-contains_key)
- [`get_value`](#function-get_value)
- [`remove`](#function-remove)
- [`remove_value`](#function-remove_value)
- [`remove_at`](#function-remove_at)
- [`try_add`](#function-try_add)
- [`try_get_value`](#function-try_get_value)

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

### new

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

Initializes a new instance.

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

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

### new_with_capacity

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

Initializes a new instance with the specified initial capacity.

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

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

### count

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

Gets the number of items in the collection.

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

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

### get

```rust
fn get(self: &Self, property: &FerroProperty) -> &TValue
```

Gets the value associated with the specified property (the getter of
the indexer by property).

Panics when the property is not found.

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

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

### set

```rust
fn set(self: &mut Self, property: &FerroProperty, value: TValue)
```

Sets the value associated with the specified property (the setter of
the indexer by property). An existing value is replaced.

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

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

### get_at

```rust
fn get_at(self: &Self, index: usize) -> &TValue
```

Gets the value at the specified index (the indexer by index).

Panics when the index is not less than `count`.

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

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

### add

```rust
fn add(self: &mut Self, property: &FerroProperty, value: TValue)
```

Adds the specified property and value to the dictionary.

Panics when the dictionary has the property already.

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

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

### clear

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

Removes all property and values from the dictionary.

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

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

### contains_key

```rust
fn contains_key(self: &Self, property: &FerroProperty) -> bool
```

Determines whether the dictionary contains the specified property.

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

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

### get_value

```rust
fn get_value(self: &Self, index: usize) -> &TValue
```

Gets the value at the specified index.

Panics when the index is not less than `count`.

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

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

### remove

```rust
fn remove(self: &mut Self, property: &FerroProperty) -> bool
```

Removes the value with the specified property from the dictionary.

Returns true if the property was found and removed; otherwise false.

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

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

### remove_value

```rust
fn remove_value(self: &mut Self, property: &FerroProperty) -> Option<TValue>
```

Removes the value with the specified property from the dictionary
and returns it, or `None` when the property was not found.

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

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

### remove_at

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

Removes the element at the specified index from the dictionary.

Panics when the index is not less than `count`.

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

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

### try_add

```rust
fn try_add(self: &mut Self, property: &FerroProperty, value: TValue) -> bool
```

Attempts to add the specified property and value to the dictionary.

Returns false when the dictionary has the property already.

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

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

### try_get_value

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

Gets the value associated with the specified property, or `None`
when the dictionary does not contain it.

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

## 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`

## Availability

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