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 is_heap_allocated(&self) -> bool
pub fn is_heap_allocated(&self) -> bool
Checks whether this vector is allocated on the heap
Sourcepub fn insert(&mut self, key: K, value: V)
pub fn insert(&mut self, key: K, value: V)
Inserts a new element into the map.
If an equal key is already present, the stored key is retained and its value is replaced. The map’s length does not change.
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.