pub struct InlineDictionary<TKey, TValue> { /* private fields */ }Expand description
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.
Implementations§
Source§impl<TKey: Clone + Eq + Hash, TValue: Default> InlineDictionary<TKey, TValue>
impl<TKey: Clone + Eq + Hash, TValue: Default> InlineDictionary<TKey, TValue>
pub fn new() -> Self
Sourcepub fn add(&mut self, key: TKey, value: TValue)
pub fn add(&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.
Sourcepub fn get(&self, key: &TKey) -> &TValue
pub fn get(&self, key: &TKey) -> &TValue
The value of a key (the getter of the indexer).
Panics when the dictionary does not have the key.
pub fn remove(&mut self, key: &TKey) -> bool
Sourcepub fn clear(&mut self)
pub fn clear(&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.
pub fn has_entries(&self) -> bool
pub fn try_get_value(&self, key: &TKey) -> Option<&TValue>
Sourcepub fn get_value_ref_or_null_ref(&mut self, key: &TKey) -> Option<&mut TValue>
pub fn get_value_ref_or_null_ref(&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.
Sourcepub fn get_value_ref_or_add_default(&mut self, key: TKey) -> (&mut TValue, bool)
pub fn get_value_ref_or_add_default(&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.
Sourcepub fn try_get_and_remove_value(&mut self, key: &TKey) -> Option<TValue>
pub fn try_get_and_remove_value(&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.
Sourcepub fn get_and_remove(&mut self, key: &TKey) -> TValue
pub fn get_and_remove(&mut self, key: &TKey) -> TValue
Removes an entry and returns its value.
Panics when try_get_and_remove_value
returns nothing.
pub fn get_enumerator(&self) -> InlineDictionaryEnumerator<'_, TKey, TValue> ⓘ
Trait Implementations§
Source§impl<'a, TKey: Clone + Eq + Hash, TValue: Default> IntoIterator for &'a InlineDictionary<TKey, TValue>
impl<'a, TKey: Clone + Eq + Hash, TValue: Default> IntoIterator for &'a InlineDictionary<TKey, TValue>
Auto Trait Implementations§
impl<TKey, TValue> Freeze for InlineDictionary<TKey, TValue>
impl<TKey, TValue> RefUnwindSafe for InlineDictionary<TKey, TValue>where
Data<TKey, TValue>: RefUnwindSafe,
TValue: RefUnwindSafe,
impl<TKey, TValue> Send for InlineDictionary<TKey, TValue>
impl<TKey, TValue> Sync for InlineDictionary<TKey, TValue>
impl<TKey, TValue> Unpin for InlineDictionary<TKey, TValue>
impl<TKey, TValue> UnsafeUnpin for InlineDictionary<TKey, TValue>where
Data<TKey, TValue>: UnsafeUnpin,
TValue: UnsafeUnpin,
impl<TKey, TValue> UnwindSafe for InlineDictionary<TKey, TValue>where
Data<TKey, TValue>: UnwindSafe,
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