Struct atomic_linked_list::atomic_map::AtomicMap
source · pub struct AtomicMap<K, V>where
K: PartialEq,{ /* private fields */ }
Implementations§
source§impl<K, V> AtomicMap<K, V>where
K: PartialEq,
impl<K, V> AtomicMap<K, V>where K: PartialEq,
sourcepub const fn new() -> AtomicMap<K, V>
pub const fn new() -> AtomicMap<K, V>
Create a new empty AtomicMap.
Does not perform any allocation until a new node is created.
sourcepub fn insert(&self, key: K, value: V) -> Option<V>
pub fn insert(&self, key: K, value: V) -> Option<V>
Adds a new key-value pair to the map. If the given key is already present, its corresponding value will be overwritten.
sourcepub fn insert_timeout(
&self,
key: K,
value: V,
max_attempts: u64
) -> Result<Option<V>, V>
pub fn insert_timeout( &self, key: K, value: V, max_attempts: u64 ) -> Result<Option<V>, V>
Adds a new key-value pair to the map. If the given key is already present, its corresponding value will be overwritten. If it fails to do so atomically after the given number of attempts, it will abort and return Err.
sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Returns a reference to the value matching the given key, if present. Otherwise, returns None.
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 matching the given key, if present.
Otherwise, returns None.
In order to maintain memory safety (to ensure atomicity), getting a value as mutable
requires self
(this AtomicMap
instance) to be borrowed mutably.
sourcepub fn iter(&self) -> AtomicMapIter<'_, K, V> ⓘ
pub fn iter(&self) -> AtomicMapIter<'_, K, V> ⓘ
Returns a forward iterator through this map.