pub struct VecMap<K, V> { /* private fields */ }Expand description
A collection that provides a map interface but is backed by vectors.
This is suitable for small key-value stores where the item count is not large enough to overcome the overhead of a more complex algorithm.
If this meets your use cases, then VecMap should be a drop-in
replacement for std::collections::HashMap or crate::HashMap. Note
that we are adding APIs on an as-needed basis. If the API you need is not
present yet, please add it!
Because it uses vectors as a backing store, the map also iterates over items
in insertion order, like crate::IndexMap.
This struct uses a struct-of-arrays (SoA) representation which tends to be more cache efficient and promotes autovectorization when using simple key or value types.
Implementations§
Source§impl<K: Eq, V> VecMap<K, V>
impl<K: Eq, V> VecMap<K, V>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Sourcepub fn entry_ref<'a, 'k>(&'a mut self, key: &'k K) -> EntryRef<'k, 'a, K, V>
pub fn entry_ref<'a, 'k>(&'a mut self, key: &'k K) -> EntryRef<'k, 'a, K, V>
Like Self::entry but takes its key by reference instead of by value.
This can be helpful if you have a key where cloning is expensive, as we can avoid cloning the key until a value is inserted under that entry.