FerroPropertyDictionary
struct · ferroui-base · v0.5.0
struct FerroPropertyDictionary<TValue>
Stores values with 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.
Members
newnew_with_capacitycountgetsetget_ataddclearcontains_keyget_valueremoveremove_valueremove_attry_addtry_get_value
new
fn new() -> Self
Initializes a new instance.
new_with_capacity
fn new_with_capacity(capacity: usize) -> Self
Initializes a new instance with the specified initial capacity.
count
fn count(self: &Self) -> usize
Gets the number of items in the collection.
get
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.
set
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.
get_at
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.
add
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.
clear
fn clear(self: &mut Self)
Removes all property and values from the dictionary.
contains_key
fn contains_key(self: &Self, property: &FerroProperty) -> bool
Determines whether the dictionary contains the specified property.
get_value
fn get_value(self: &Self, index: usize) -> &TValue
Gets the value at the specified index.
Panics when the index is not less than count.
remove
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.
remove_value
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.
remove_at
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.
try_add
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.
try_get_value
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherDefault
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.