InlineDictionary
struct · ferroui-base · v0.5.0
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.
Members
newaddsetgetremoveclearhas_entriestry_get_valueget_value_ref_or_null_refget_value_ref_or_add_defaulttry_get_and_remove_valueget_and_removeget_enumerator
new
fn new() -> Self
add
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.
set
fn set(self: &mut Self, key: TKey, value: TValue)
Adds an entry or replaces its value.
get
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.
remove
fn remove(self: &mut Self, key: &TKey) -> bool
clear
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.
has_entries
fn has_entries(self: &Self) -> bool
try_get_value
fn try_get_value(self: &Self, key: &TKey) -> Option<&TValue>
get_value_ref_or_null_ref
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.
get_value_ref_or_add_default
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.
try_get_and_remove_value
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.
get_and_remove
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.
get_enumerator
fn get_enumerator(self: &Self) -> InlineDictionaryEnumerator<'_, TKey, TValue>
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherDefaultIntoIterator
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.