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,

source

pub fn insert(&self, key: K, value: impl Into<Arc<V>>) -> Arc<V>

Insert a new value for the given key in the map.

source

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.

source

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.

source

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.

source

pub fn remove<Q>(&self, key: &Q)where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Sets the key as removed in the map.

source

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.

source

pub fn for_each(&self, callback: impl FnMut(&K, &mut Arc<V>))

Call the function for all additive keys.

source

pub fn len(&self) -> usize

Returns the number of keys.

source

pub fn capacity(&self) -> usize

Return the size of all allocated items.

source

pub fn is_empty(&self) -> bool

True if the map doesn’t contain any items.

Trait Implementations§

source§

impl<K: Clone + 'static + Key, V: Clone + 'static + Value> Clone for Map<K, V>

source§

fn clone(&self) -> Map<K, V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K: Default + 'static + Key, V: Default + 'static + Value> Default for Map<K, V>

source§

fn default() -> Map<K, V>

Returns the “default value” for a type. Read more
source§

impl<K, V> Index for Map<K, V>where K: Key + Clone, V: Value + Clone,

source§

fn store_all(&mut self) -> Result<Vec<Intent<Box<dyn Store>>>>

Generate an Intent wrapper for each field in the Index. Read more
source§

fn load_all(&mut self) -> Result<Vec<Intent<Box<dyn Load>>>>

Generate an Intent wrapper for each field in the Index. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V