pub struct FerroPropertyDictionary<TValue> { /* private fields */ }Expand description
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.
Implementations§
Source§impl<TValue> FerroPropertyDictionary<TValue>
impl<TValue> FerroPropertyDictionary<TValue>
Sourcepub fn new_with_capacity(capacity: usize) -> Self
pub fn new_with_capacity(capacity: usize) -> Self
Initializes a new instance with the specified initial capacity.
Sourcepub fn get(&self, property: &FerroProperty) -> &TValue
pub fn get(&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.
Sourcepub fn set(&mut self, property: &FerroProperty, value: TValue)
pub fn set(&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.
Sourcepub fn get_at(&self, index: usize) -> &TValue
pub fn get_at(&self, index: usize) -> &TValue
Gets the value at the specified index (the indexer by index).
Panics when the index is not less than count.
Sourcepub fn add(&mut self, property: &FerroProperty, value: TValue)
pub fn add(&mut self, property: &FerroProperty, value: TValue)
Adds the specified property and value to the dictionary.
Panics when the dictionary has the property already.
Sourcepub fn contains_key(&self, property: &FerroProperty) -> bool
pub fn contains_key(&self, property: &FerroProperty) -> bool
Determines whether the dictionary contains the specified property.
Sourcepub fn get_value(&self, index: usize) -> &TValue
pub fn get_value(&self, index: usize) -> &TValue
Gets the value at the specified index.
Panics when the index is not less than count.
Sourcepub fn remove(&mut self, property: &FerroProperty) -> bool
pub fn remove(&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.
Sourcepub fn remove_value(&mut self, property: &FerroProperty) -> Option<TValue>
pub fn remove_value(&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.
Sourcepub fn remove_at(&mut self, index: usize)
pub fn remove_at(&mut self, index: usize)
Removes the element at the specified index from the dictionary.
Panics when the index is not less than count.
Sourcepub fn try_add(&mut self, property: &FerroProperty, value: TValue) -> bool
pub fn try_add(&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.
Sourcepub fn try_get_value(&self, property: &FerroProperty) -> Option<&TValue>
pub fn try_get_value(&self, property: &FerroProperty) -> Option<&TValue>
Gets the value associated with the specified property, or None
when the dictionary does not contain it.
Trait Implementations§
Auto Trait Implementations§
impl<TValue> Freeze for FerroPropertyDictionary<TValue>
impl<TValue> RefUnwindSafe for FerroPropertyDictionary<TValue>where
Vec<Entry<TValue>>: RefUnwindSafe,
impl<TValue> Send for FerroPropertyDictionary<TValue>
impl<TValue> Sync for FerroPropertyDictionary<TValue>
impl<TValue> Unpin for FerroPropertyDictionary<TValue>
impl<TValue> UnsafeUnpin for FerroPropertyDictionary<TValue>where
Vec<Entry<TValue>>: UnsafeUnpin,
impl<TValue> UnwindSafe for FerroPropertyDictionary<TValue>where
Vec<Entry<TValue>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more