Struct tl::inline::hashmap::InlineHashMap
source · pub struct InlineHashMap<K, V, const N: usize>(/* private fields */);
Expand description
Similar to InlineVec, this structure will use an array if it is small enough to live on the stack, otherwise it allocates a HashMap on the heap
Hashing can be slower than just iterating through an array if the array is small, which is where it makes most sense
Implementations§
source§impl<K, V, const N: usize> InlineHashMap<K, V, N>
impl<K, V, const N: usize> InlineHashMap<K, V, N>
sourcepub fn iter(&self) -> Box<dyn Iterator<Item = (&K, &V)> + '_>
pub fn iter(&self) -> Box<dyn Iterator<Item = (&K, &V)> + '_>
Returns an iterator over the elements of this map
This function boxes the returned iterator because it can be either of two:
- The iterator returned by
HashMap::iter()
- The iterator over a stack-allocated array
sourcepub fn inline_parts_mut(
&mut self
) -> Option<(&mut [MaybeUninit<(K, V)>; N], usize)>
pub fn inline_parts_mut( &mut self ) -> Option<(&mut [MaybeUninit<(K, V)>; N], usize)>
If self
is inlined, this returns the underlying raw parts that make up this InlineHashMap
.
Only the first .1
elements are initialized.
sourcepub fn is_heap_allocated(&self) -> bool
pub fn is_heap_allocated(&self) -> bool
Checks whether this vector is allocated on the heap
sourcepub fn remove(&mut self, key: &K) -> Option<V>
pub fn remove(&mut self, key: &K) -> Option<V>
Removes an element from the map, and returns ownership over the value
sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Returns a reference to the value corresponding to the key.
sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Checks whether the map contains a value for the specified key.