Struct infinitree::fields::Map
source · pub struct Map<K: 'static + Key, V: 'static + Value>(_);
Expand description
Multithreaded hash map that is always saved atomically
Calling clone()
will create a reference to the
same instance, and can be easily shared between threads.
For tracking incremental changes to your data structure, look at
VersionedMap
Implementations§
source§impl<K, V> Map<K, V>where
K: Key,
V: Value,
impl<K, V> Map<K, V>where K: Key, V: Value,
sourcepub fn insert(&self, key: K, value: impl Into<Arc<V>>) -> Arc<V>
pub fn insert(&self, key: K, value: impl Into<Arc<V>>) -> Arc<V>
Insert a new value for the given key in the map.
sourcepub fn update_with<Q, R>(
&self,
key: &Q,
fun: impl FnOnce(&K, &mut Arc<V>) -> R
) -> Option<R>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn update_with<Q, R>( &self, key: &Q, fun: impl FnOnce(&K, &mut Arc<V>) -> R ) -> Option<R>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
Update a value with the given key, and return the new value if the key exists.
sourcepub fn insert_with(&self, key: K, fun: impl FnMut() -> V) -> Arc<V>
pub fn insert_with(&self, key: K, fun: impl FnMut() -> V) -> Arc<V>
Call the given function to insert a value if it doesn’t exist. Return with the current value to the key.
sourcepub fn get<Q>(&self, key: &Q) -> Option<Arc<V>>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<Arc<V>>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
Returns the stored value for a key, or None
.
sourcepub fn remove<Q>(&self, key: &Q)where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&self, key: &Q)where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
Sets the key as removed in the map.
sourcepub fn contains<Q>(&self, key: &Q) -> boolwhere
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn contains<Q>(&self, key: &Q) -> boolwhere K: Borrow<Q>, Q: Hash + Eq + ?Sized,
Returns if there’s an addition for the specified key.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for Map<K, V>
impl<K, V> Send for Map<K, V>
impl<K, V> Sync for Map<K, V>
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V>
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