pub struct HashMap<K: 'static, V: 'static, S = FixedState> { /* private fields */ }Expand description
High-Performance Lock-Free Map.
Implementations§
Source§impl<K, V> HashMap<K, V, FixedState>
impl<K, V> HashMap<K, V, FixedState>
Source§impl<K, V, S> HashMap<K, V, S>
impl<K, V, S> HashMap<K, V, S>
Sourcepub fn with_hasher(hasher: S) -> Self
pub fn with_hasher(hasher: S) -> Self
Creates a new hash map with custom hasher.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Checks if the key exists.
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 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.
This is linearizable: concurrent callers for the same key are guaranteed to agree on which value was inserted (exactly one thread’s CAS succeeds at the list tail, and all others see that node on retry).
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the map. Note: This is an O(N) operation as it scans all buckets.
Sourcepub fn iter(&self) -> Iter<'_, K, V, S> ⓘ
pub fn iter(&self) -> Iter<'_, K, V, S> ⓘ
Returns an iterator over the map entries. Yields (K, V) clones.
Trait Implementations§
Source§impl<K, V> Default for HashMap<K, V, FixedState>
Available on crate feature std only.
impl<K, V> Default for HashMap<K, V, FixedState>
Available on crate feature
std only.Source§impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S>
impl<K: Send, V: Send, S: Send> Send for HashMap<K, V, S>
impl<K: Send + Sync, V: Send + Sync, S: Send + Sync> Sync for HashMap<K, V, S>
Auto Trait Implementations§
impl<K, V, S> Freeze for HashMap<K, V, S>where
S: Freeze,
impl<K, V, S = FixedState> !RefUnwindSafe for HashMap<K, V, S>
impl<K, V, S> Unpin for HashMap<K, V, S>where
S: Unpin,
impl<K, V, S> UnsafeUnpin for HashMap<K, V, S>where
S: UnsafeUnpin,
impl<K, V, S = FixedState> !UnwindSafe for HashMap<K, V, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more