Struct infinitree::fields::Map
source · [−]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
sourceimpl<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) -> bool where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn contains<Q>(&self, key: &Q) -> bool where
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more