pub struct HopscotchMap<K: 'static, V: 'static, S = FixedState> { /* private fields */ }Expand description
A concurrent, lock-free hash map based on Hopscotch Hashing.
Implementations§
Source§impl<K, V> HopscotchMap<K, V, FixedState>
impl<K, V> HopscotchMap<K, V, FixedState>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new HopscotchMap with the specified capacity and default hasher.
Source§impl<K, V, S> HopscotchMap<K, V, S>
impl<K, V, S> HopscotchMap<K, V, S>
Sourcepub fn with_hasher(hasher: S) -> Self
pub fn with_hasher(hasher: S) -> Self
Creates a new HopscotchMap with the specified hasher and default capacity.
Sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> Self
Creates a new HopscotchMap with the specified capacity and hasher.
Sourcepub fn get_or_insert(&self, key: K, value: V) -> V
pub fn get_or_insert(&self, key: K, value: V) -> V
Returns the value corresponding to the key, or inserts the given value if the key is not present.
When multiple threads call this concurrently for the same key, all callers are guaranteed to receive the same value (the one visible in the map).
Sourcepub fn insert_if_absent(&self, key: K, value: V) -> Option<V>
pub fn insert_if_absent(&self, key: K, value: V) -> Option<V>
Insert a key-value pair only if the key does not exist.
Returns None if inserted, Some(existing_value) if the key already exists.
Sourcepub fn remove<Q>(&self, key: &Q) -> Option<V>
pub fn remove<Q>(&self, key: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key was previously in the map.
Sourcepub fn iter(&self) -> HopscotchIter<'_, K, V, S> ⓘ
pub fn iter(&self) -> HopscotchIter<'_, K, V, S> ⓘ
Returns an iterator over the map entries.
Sourcepub fn keys(&self) -> HopscotchKeys<'_, K, V, S> ⓘ
pub fn keys(&self) -> HopscotchKeys<'_, K, V, S> ⓘ
Returns an iterator over the map keys.
Trait Implementations§
Source§impl<K, V> Default for HopscotchMap<K, V, FixedState>
Available on crate feature std only.
impl<K, V> Default for HopscotchMap<K, V, FixedState>
std only.