pub struct DashMap<K, V, S = RandomState> { /* private fields */ }
Expand description
DashMap is an implementation of a concurrent associative array/hashmap in Rust.
DashMap tries to implement an easy to use API similar to std::collections::HashMap
with some slight changes to handle concurrency.
DashMap tries to be very simple to use and to be a direct replacement for RwLock<HashMap<K, V, S>>
.
To accomplish this, all methods take &self
instead of modifying methods taking &mut self
.
This allows you to put a DashMap in an Arc<T>
and share it between threads while being able to modify it.
Documentation mentioning locking behaviour acts in the reference frame of the calling thread. This means that it is safe to ignore it across multiple threads.
Implementations
sourceimpl<'a, K, V, S> DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
impl<'a, K, V, S> DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
pub fn par_iter_mut(&self) -> IterMut<'_, K, V, S>
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V, RandomState>
impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V, RandomState>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new DashMap with a capacity of 0.
Examples
use dashmap::DashMap;
let reviews = DashMap::new();
reviews.insert("Veloren", "What a fantastic game!");
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new DashMap with a specified starting capacity.
Examples
use dashmap::DashMap;
let mappings = DashMap::with_capacity(2);
mappings.insert(2, 4);
mappings.insert(8, 16);
sourcepub fn with_shard_amount(shard_amount: usize) -> Self
pub fn with_shard_amount(shard_amount: usize) -> Self
Creates a new DashMap with a specified shard amount
shard_amount should greater than 0 and be a power of two. If a shard_amount which is not a power of two is provided, the function will panic.
Examples
use dashmap::DashMap;
let mappings = DashMap::with_shard_amount(32);
mappings.insert(2, 4);
mappings.insert(8, 16);
sourcepub fn with_capacity_and_shard_amount(
capacity: usize,
shard_amount: usize
) -> Self
pub fn with_capacity_and_shard_amount(
capacity: usize,
shard_amount: usize
) -> Self
Creates a new DashMap with a specified capacity and shard amount.
shard_amount should greater than 0 and be a power of two. If a shard_amount which is not a power of two is provided, the function will panic.
Examples
use dashmap::DashMap;
let mappings = DashMap::with_capacity_and_shard_amount(32, 32);
mappings.insert(2, 4);
mappings.insert(8, 16);
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S>
impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S>
sourcepub fn into_read_only(self) -> ReadOnlyView<K, V, S>
pub fn into_read_only(self) -> ReadOnlyView<K, V, S>
Wraps this DashMap
into a read-only view. This view allows to obtain raw references to the stored values.
sourcepub fn with_hasher(hasher: S) -> Self
pub fn with_hasher(hasher: S) -> Self
Creates a new DashMap with a capacity of 0 and the provided hasher.
Examples
use dashmap::DashMap;
use std::collections::hash_map::RandomState;
let s = RandomState::new();
let reviews = DashMap::with_hasher(s);
reviews.insert("Veloren", "What a fantastic game!");
sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> Self
Creates a new DashMap with a specified starting capacity and hasher.
Examples
use dashmap::DashMap;
use std::collections::hash_map::RandomState;
let s = RandomState::new();
let mappings = DashMap::with_capacity_and_hasher(2, s);
mappings.insert(2, 4);
mappings.insert(8, 16);
sourcepub fn with_hasher_and_shard_amount(hasher: S, shard_amount: usize) -> Self
pub fn with_hasher_and_shard_amount(hasher: S, shard_amount: usize) -> Self
Creates a new DashMap with a specified hasher and shard amount
shard_amount should be greater than 0 and a power of two. If a shard_amount which is not a power of two is provided, the function will panic.
Examples
use dashmap::DashMap;
use std::collections::hash_map::RandomState;
let s = RandomState::new();
let mappings = DashMap::with_hasher_and_shard_amount(s, 32);
mappings.insert(2, 4);
mappings.insert(8, 16);
sourcepub fn with_capacity_and_hasher_and_shard_amount(
capacity: usize,
hasher: S,
shard_amount: usize
) -> Self
pub fn with_capacity_and_hasher_and_shard_amount(
capacity: usize,
hasher: S,
shard_amount: usize
) -> Self
Creates a new DashMap with a specified starting capacity, hasher and shard_amount.
shard_amount should greater than 0 and be a power of two. If a shard_amount which is not a power of two is provided, the function will panic.
Examples
use dashmap::DashMap;
use std::collections::hash_map::RandomState;
let s = RandomState::new();
let mappings = DashMap::with_capacity_and_hasher_and_shard_amount(2, s, 32);
mappings.insert(2, 4);
mappings.insert(8, 16);
sourcepub fn hash_usize<T: Hash>(&self, item: &T) -> usize
pub fn hash_usize<T: Hash>(&self, item: &T) -> usize
Hash a given item to produce a usize. Uses the provided or default HashBuilder.
sourcepub fn shards(&self) -> &[RwLock<HashMap<K, SharedValue<V>, S>>]
pub fn shards(&self) -> &[RwLock<HashMap<K, SharedValue<V>, S>>]
Allows you to peek at the inner shards that store your data. You should probably not use this unless you know what you are doing.
Requires the raw-api
feature to be enabled.
Examples
use dashmap::DashMap;
let map = DashMap::<(), ()>::new();
println!("Amount of shards: {}", map.shards().len());
sourcepub fn determine_map<Q>(&self, key: &Q) -> usize where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn determine_map<Q>(&self, key: &Q) -> usize where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Finds which shard a certain key is stored in. You should probably not use this unless you know what you are doing. Note that shard selection is dependent on the default or provided HashBuilder.
Requires the raw-api
feature to be enabled.
Examples
use dashmap::DashMap;
let map = DashMap::new();
map.insert("coca-cola", 1.4);
println!("coca-cola is stored in shard: {}", map.determine_map("coca-cola"));
sourcepub fn determine_shard(&self, hash: usize) -> usize
pub fn determine_shard(&self, hash: usize) -> usize
Finds which shard a certain hash is stored in.
Requires the raw-api
feature to be enabled.
Examples
use dashmap::DashMap;
let map: DashMap<i32, i32> = DashMap::new();
let key = "key";
let hash = map.hash_usize(&key);
println!("hash is stored in shard: {}", map.determine_shard(hash));
sourcepub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
Examples
use dashmap::DashMap;
use std::collections::hash_map::RandomState;
let hasher = RandomState::new();
let map: DashMap<i32, i32> = DashMap::new();
let hasher: &RandomState = map.hasher();
sourcepub fn insert(&self, key: K, value: V) -> Option<V>
pub fn insert(&self, key: K, value: V) -> Option<V>
Inserts a key and a value into the map. Returns the old value associated with the key if there was one.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let map = DashMap::new();
map.insert("I am the key!", "And I am the value!");
sourcepub fn remove<Q>(&self, key: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&self, key: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Removes an entry from the map, returning the key and value if they existed in the map.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let soccer_team = DashMap::new();
soccer_team.insert("Jack", "Goalie");
assert_eq!(soccer_team.remove("Jack").unwrap().1, "Goalie");
sourcepub fn remove_if<Q>(
&self,
key: &Q,
f: impl FnOnce(&K, &V) -> bool
) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove_if<Q>(
&self,
key: &Q,
f: impl FnOnce(&K, &V) -> bool
) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Removes an entry from the map, returning the key and value if the entry existed and the provided conditional function returned true.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
use dashmap::DashMap;
let soccer_team = DashMap::new();
soccer_team.insert("Sam", "Forward");
soccer_team.remove_if("Sam", |_, position| position == &"Goalie");
assert!(soccer_team.contains_key("Sam"));
use dashmap::DashMap;
let soccer_team = DashMap::new();
soccer_team.insert("Sam", "Forward");
soccer_team.remove_if("Sam", |_, position| position == &"Forward");
assert!(!soccer_team.contains_key("Sam"));
pub fn remove_if_mut<Q>(
&self,
key: &Q,
f: impl FnOnce(&K, &mut V) -> bool
) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
sourcepub fn iter(&'a self) -> Iter<'a, K, V, S, DashMap<K, V, S>>ⓘNotable traits for Iter<'a, K, V, S, M>impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iterator for Iter<'a, K, V, S, M> type Item = RefMulti<'a, K, V, S>;
pub fn iter(&'a self) -> Iter<'a, K, V, S, DashMap<K, V, S>>ⓘNotable traits for Iter<'a, K, V, S, M>impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iterator for Iter<'a, K, V, S, M> type Item = RefMulti<'a, K, V, S>;
Creates an iterator over a DashMap yielding immutable references.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap;
let words = DashMap::new();
words.insert("hello", "world");
assert_eq!(words.iter().count(), 1);
sourcepub fn iter_mut(&'a self) -> IterMut<'a, K, V, S, DashMap<K, V, S>>ⓘNotable traits for IterMut<'a, K, V, S, M>impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iterator for IterMut<'a, K, V, S, M> type Item = RefMutMulti<'a, K, V, S>;
pub fn iter_mut(&'a self) -> IterMut<'a, K, V, S, DashMap<K, V, S>>ⓘNotable traits for IterMut<'a, K, V, S, M>impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iterator for IterMut<'a, K, V, S, M> type Item = RefMutMulti<'a, K, V, S>;
Iterator over a DashMap yielding mutable references.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let map = DashMap::new();
map.insert("Johnny", 21);
map.iter_mut().for_each(|mut r| *r += 1);
assert_eq!(*map.get("Johnny").unwrap(), 22);
sourcepub fn get<Q>(&'a self, key: &Q) -> Option<Ref<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get<Q>(&'a self, key: &Q) -> Option<Ref<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Get a immutable reference to an entry in the map
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap;
let youtubers = DashMap::new();
youtubers.insert("Bosnian Bill", 457000);
assert_eq!(*youtubers.get("Bosnian Bill").unwrap(), 457000);
sourcepub fn get_mut<Q>(&'a self, key: &Q) -> Option<RefMut<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn get_mut<Q>(&'a self, key: &Q) -> Option<RefMut<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Get a mutable reference to an entry in the map
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let class = DashMap::new();
class.insert("Albin", 15);
*class.get_mut("Albin").unwrap() -= 1;
assert_eq!(*class.get("Albin").unwrap(), 14);
sourcepub fn try_get<Q>(&'a self, key: &Q) -> TryResult<Ref<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn try_get<Q>(&'a self, key: &Q) -> TryResult<Ref<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Get an immutable reference to an entry in the map, if the shard is not locked. If the shard is locked, the function will return TryResult::Locked.
Examples
use dashmap::DashMap;
use dashmap::try_result::TryResult;
let map = DashMap::new();
map.insert("Johnny", 21);
assert_eq!(*map.try_get("Johnny").unwrap(), 21);
let _result1_locking = map.get_mut("Johnny");
let result2 = map.try_get("Johnny");
assert!(result2.is_locked());
sourcepub fn try_get_mut<Q>(&'a self, key: &Q) -> TryResult<RefMut<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn try_get_mut<Q>(&'a self, key: &Q) -> TryResult<RefMut<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Get a mutable reference to an entry in the map, if the shard is not locked. If the shard is locked, the function will return TryResult::Locked.
Examples
use dashmap::DashMap;
use dashmap::try_result::TryResult;
let map = DashMap::new();
map.insert("Johnny", 21);
*map.try_get_mut("Johnny").unwrap() += 1;
assert_eq!(*map.get("Johnny").unwrap(), 22);
let _result1_locking = map.get("Johnny");
let result2 = map.try_get_mut("Johnny");
assert!(result2.is_locked());
sourcepub fn shrink_to_fit(&self)
pub fn shrink_to_fit(&self)
Remove excess capacity to reduce memory usage.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
sourcepub fn retain(&self, f: impl FnMut(&K, &mut V) -> bool)
pub fn retain(&self, f: impl FnMut(&K, &mut V) -> bool)
Retain elements that whose predicates return true and discard elements whose predicates return false.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let people = DashMap::new();
people.insert("Albin", 15);
people.insert("Jones", 22);
people.insert("Charlie", 27);
people.retain(|_, v| *v > 20);
assert_eq!(people.len(), 2);
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Fetches the total number of key-value pairs stored in the map.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap;
let people = DashMap::new();
people.insert("Albin", 15);
people.insert("Jones", 22);
people.insert("Charlie", 27);
assert_eq!(people.len(), 3);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the map is empty or not.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap;
let map = DashMap::<(), ()>::new();
assert!(map.is_empty());
sourcepub fn clear(&self)
pub fn clear(&self)
Removes all key-value pairs in the map.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let stats = DashMap::new();
stats.insert("Goals", 4);
assert!(!stats.is_empty());
stats.clear();
assert!(stats.is_empty());
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns how many key-value pairs the map can store without reallocating.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
sourcepub fn alter<Q>(&self, key: &Q, f: impl FnOnce(&K, V) -> V) where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn alter<Q>(&self, key: &Q, f: impl FnOnce(&K, V) -> V) where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Modify a specific value according to a function.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let stats = DashMap::new();
stats.insert("Goals", 4);
stats.alter("Goals", |_, v| v * 2);
assert_eq!(*stats.get("Goals").unwrap(), 8);
Panics
If the given closure panics, then alter
will abort the process
sourcepub fn alter_all(&self, f: impl FnMut(&K, V) -> V)
pub fn alter_all(&self, f: impl FnMut(&K, V) -> V)
Modify every value in the map according to a function.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let stats = DashMap::new();
stats.insert("Wins", 4);
stats.insert("Losses", 2);
stats.alter_all(|_, v| v + 1);
assert_eq!(*stats.get("Wins").unwrap(), 5);
assert_eq!(*stats.get("Losses").unwrap(), 3);
Panics
If the given closure panics, then alter_all
will abort the process
sourcepub fn view<Q, R>(&self, key: &Q, f: impl FnOnce(&K, &V) -> R) -> Option<R> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn view<Q, R>(&self, key: &Q, f: impl FnOnce(&K, &V) -> R) -> Option<R> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Scoped access into an item of the map according to a function.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
Examples
use dashmap::DashMap;
let warehouse = DashMap::new();
warehouse.insert(4267, ("Banana", 100));
warehouse.insert(2359, ("Pear", 120));
let fruit = warehouse.view(&4267, |_k, v| *v);
assert_eq!(fruit, Some(("Banana", 100)));
Panics
If the given closure panics, then view
will abort the process
sourcepub fn contains_key<Q>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn contains_key<Q>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Checks if the map contains a specific key.
Locking behaviour: May deadlock if called when holding a mutable reference into the map.
Examples
use dashmap::DashMap;
let team_sizes = DashMap::new();
team_sizes.insert("Dakota Cherries", 23);
assert!(team_sizes.contains_key("Dakota Cherries"));
sourcepub fn entry(&'a self, key: K) -> Entry<'a, K, V, S>
pub fn entry(&'a self, key: K) -> Entry<'a, K, V, S>
Advanced entry API that tries to mimic std::collections::HashMap
.
See the documentation on dashmap::mapref::entry
for more details.
Locking behaviour: May deadlock if called when holding any sort of reference into the map.
sourcepub fn try_entry(&'a self, key: K) -> Option<Entry<'a, K, V, S>>
pub fn try_entry(&'a self, key: K) -> Option<Entry<'a, K, V, S>>
Advanced entry API that tries to mimic std::collections::HashMap
.
See the documentation on dashmap::mapref::entry
for more details.
Returns None if the shard is currently locked.
sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Advanced entry API that tries to mimic std::collections::HashMap::try_reserve
.
Tries to reserve capacity for at least shard * additional
and may reserve more space to avoid frequent reallocations.
Errors
If the capacity overflows, or the allocator reports a failure, then an error is returned.
Trait Implementations
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone, Q> BitAnd<&Q> for &'a DashMap<K, V, S> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone, Q> BitAnd<&Q> for &'a DashMap<K, V, S> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone, Q> BitOr<&Q> for &'a DashMap<K, V, S> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone, Q> BitOr<&Q> for &'a DashMap<K, V, S> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
sourceimpl<K, V, S> Default for DashMap<K, V, S> where
K: Eq + Hash,
S: Default + BuildHasher + Clone,
impl<K, V, S> Default for DashMap<K, V, S> where
K: Eq + Hash,
S: Default + BuildHasher + Clone,
sourceimpl<'de, K, V, S> Deserialize<'de> for DashMap<K, V, S> where
K: Deserialize<'de> + Eq + Hash,
V: Deserialize<'de>,
S: BuildHasher + Clone + Default,
impl<'de, K, V, S> Deserialize<'de> for DashMap<K, V, S> where
K: Deserialize<'de> + Eq + Hash,
V: Deserialize<'de>,
S: BuildHasher + Clone + Default,
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<K: Eq + Hash, V, S: BuildHasher + Clone> Extend<(K, V)> for DashMap<K, V, S>
impl<K: Eq + Hash, V, S: BuildHasher + Clone> Extend<(K, V)> for DashMap<K, V, S>
sourcefn extend<I: IntoIterator<Item = (K, V)>>(&mut self, intoiter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, intoiter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<K: Eq + Hash, V, S: BuildHasher + Clone + Default> FromIterator<(K, V)> for DashMap<K, V, S>
impl<K: Eq + Hash, V, S: BuildHasher + Clone + Default> FromIterator<(K, V)> for DashMap<K, V, S>
sourcefn from_iter<I: IntoIterator<Item = (K, V)>>(intoiter: I) -> Self
fn from_iter<I: IntoIterator<Item = (K, V)>>(intoiter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<K, V, S> FromParallelIterator<(K, V)> for DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + Default + BuildHasher,
impl<K, V, S> FromParallelIterator<(K, V)> for DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + Default + BuildHasher,
sourcefn from_par_iter<I>(par_iter: I) -> Self where
I: IntoParallelIterator<Item = (K, V)>,
fn from_par_iter<I>(par_iter: I) -> Self where
I: IntoParallelIterator<Item = (K, V)>,
Creates an instance of the collection from the parallel iterator par_iter
. Read more
sourceimpl<'a, K: Eq + Hash, V, S: BuildHasher + Clone> IntoIterator for &'a DashMap<K, V, S>
impl<'a, K: Eq + Hash, V, S: BuildHasher + Clone> IntoIterator for &'a DashMap<K, V, S>
sourceimpl<'a, K: Eq + Hash, V, S: BuildHasher + Clone> IntoIterator for DashMap<K, V, S>
impl<'a, K: Eq + Hash, V, S: BuildHasher + Clone> IntoIterator for DashMap<K, V, S>
sourceimpl<'a, K, V, S> IntoParallelIterator for &'a DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
impl<'a, K, V, S> IntoParallelIterator for &'a DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
sourceimpl<'a, K, V, S> IntoParallelIterator for &'a mut DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
impl<'a, K, V, S> IntoParallelIterator for &'a mut DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
type Item = RefMutMulti<'a, K, V, S>
type Item = RefMutMulti<'a, K, V, S>
The type of item that the parallel iterator will produce.
sourcefn into_par_iter(self) -> Self::Iter
fn into_par_iter(self) -> Self::Iter
Converts self
into a parallel iterator. Read more
sourceimpl<K, V, S> IntoParallelIterator for DashMap<K, V, S> where
K: Send + Eq + Hash,
V: Send,
S: Send + Clone + BuildHasher,
impl<K, V, S> IntoParallelIterator for DashMap<K, V, S> where
K: Send + Eq + Hash,
V: Send,
S: Send + Clone + BuildHasher,
type Iter = OwningIter<K, V, S>
type Iter = OwningIter<K, V, S>
The parallel iterator type that will be created.
sourcefn into_par_iter(self) -> Self::Iter
fn into_par_iter(self) -> Self::Iter
Converts self
into a parallel iterator. Read more
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a, S: 'a + BuildHasher + Clone> Map<'a, K, V, S> for DashMap<K, V, S>
impl<'a, K: 'a + Eq + Hash, V: 'a, S: 'a + BuildHasher + Clone> Map<'a, K, V, S> for DashMap<K, V, S>
fn _shard_count(&self) -> usize
sourceunsafe fn _get_read_shard(
&'a self,
i: usize
) -> &'a HashMap<K, SharedValue<V>, S>
unsafe fn _get_read_shard(
&'a self,
i: usize
) -> &'a HashMap<K, SharedValue<V>, S>
Safety Read more
sourceunsafe fn _yield_read_shard(
&'a self,
i: usize
) -> RwLockReadGuard<'a, HashMap<K, SharedValue<V>, S>>
unsafe fn _yield_read_shard(
&'a self,
i: usize
) -> RwLockReadGuard<'a, HashMap<K, SharedValue<V>, S>>
Safety Read more
sourceunsafe fn _yield_write_shard(
&'a self,
i: usize
) -> RwLockWriteGuard<'a, HashMap<K, SharedValue<V>, S>>
unsafe fn _yield_write_shard(
&'a self,
i: usize
) -> RwLockWriteGuard<'a, HashMap<K, SharedValue<V>, S>>
Safety Read more
sourceunsafe fn _try_yield_read_shard(
&'a self,
i: usize
) -> Option<RwLockReadGuard<'a, HashMap<K, SharedValue<V>, S>>>
unsafe fn _try_yield_read_shard(
&'a self,
i: usize
) -> Option<RwLockReadGuard<'a, HashMap<K, SharedValue<V>, S>>>
Safety Read more
sourceunsafe fn _try_yield_write_shard(
&'a self,
i: usize
) -> Option<RwLockWriteGuard<'a, HashMap<K, SharedValue<V>, S>>>
unsafe fn _try_yield_write_shard(
&'a self,
i: usize
) -> Option<RwLockWriteGuard<'a, HashMap<K, SharedValue<V>, S>>>
Safety Read more
fn _insert(&self, key: K, value: V) -> Option<V>
fn _remove<Q>(&self, key: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _remove_if<Q>(&self, key: &Q, f: impl FnOnce(&K, &V) -> bool) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _remove_if_mut<Q>(
&self,
key: &Q,
f: impl FnOnce(&K, &mut V) -> bool
) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _iter(&'a self) -> Iter<'a, K, V, S, DashMap<K, V, S>>ⓘNotable traits for Iter<'a, K, V, S, M>impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iterator for Iter<'a, K, V, S, M> type Item = RefMulti<'a, K, V, S>;
fn _iter_mut(&'a self) -> IterMut<'a, K, V, S, DashMap<K, V, S>>ⓘNotable traits for IterMut<'a, K, V, S, M>impl<'a, K: Eq + Hash, V, S: 'a + BuildHasher + Clone, M: Map<'a, K, V, S>> Iterator for IterMut<'a, K, V, S, M> type Item = RefMutMulti<'a, K, V, S>;
fn _get<Q>(&'a self, key: &Q) -> Option<Ref<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _get_mut<Q>(&'a self, key: &Q) -> Option<RefMut<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _try_get<Q>(&'a self, key: &Q) -> TryResult<Ref<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _try_get_mut<Q>(&'a self, key: &Q) -> TryResult<RefMut<'a, K, V, S>> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _shrink_to_fit(&self)
fn _retain(&self, f: impl FnMut(&K, &mut V) -> bool)
fn _len(&self) -> usize
fn _capacity(&self) -> usize
fn _alter<Q>(&self, key: &Q, f: impl FnOnce(&K, V) -> V) where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _alter_all(&self, f: impl FnMut(&K, V) -> V)
fn _view<Q, R>(&self, key: &Q, f: impl FnOnce(&K, &V) -> R) -> Option<R> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _entry(&'a self, key: K) -> Entry<'a, K, V, S>
fn _try_entry(&'a self, key: K) -> Option<Entry<'a, K, V, S>>
fn _hasher(&self) -> S
fn _clear(&self)
fn _contains_key<Q>(&'a self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
fn _is_empty(&self) -> bool
sourceimpl<K, V, S> ParallelExtend<(K, V)> for &DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
impl<K, V, S> ParallelExtend<(K, V)> for &DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
sourcefn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = (K, V)>,
fn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = (K, V)>,
Extends an instance of the collection with the elements drawn
from the parallel iterator par_iter
. Read more
sourceimpl<K, V, S> ParallelExtend<(K, V)> for DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
impl<K, V, S> ParallelExtend<(K, V)> for DashMap<K, V, S> where
K: Send + Sync + Eq + Hash,
V: Send + Sync,
S: Send + Sync + Clone + BuildHasher,
sourcefn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = (K, V)>,
fn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = (K, V)>,
Extends an instance of the collection with the elements drawn
from the parallel iterator par_iter
. Read more
sourceimpl<K, V, H> Serialize for DashMap<K, V, H> where
K: Serialize + Eq + Hash,
V: Serialize,
H: BuildHasher + Clone,
impl<K, V, H> Serialize for DashMap<K, V, H> where
K: Serialize + Eq + Hash,
V: Serialize,
H: BuildHasher + Clone,
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> Shl<(K, V)> for &'a DashMap<K, V, S>
impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> Shl<(K, V)> for &'a DashMap<K, V, S>
sourceimpl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone, Q> Shr<&Q> for &'a DashMap<K, V, S> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone, Q> Shr<&Q> for &'a DashMap<K, V, S> where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Auto Trait Implementations
impl<K, V, S = RandomState> !RefUnwindSafe for DashMap<K, V, S>
impl<K, V, S> Send for DashMap<K, V, S> where
K: Send,
S: Send,
V: Send,
impl<K, V, S> Sync for DashMap<K, V, S> where
K: Send + Sync,
S: Send + Sync,
V: Send + Sync,
impl<K, V, S> Unpin for DashMap<K, V, S> where
S: Unpin,
impl<K, V, S> UnwindSafe for DashMap<K, V, S> where
K: UnwindSafe,
S: UnwindSafe,
V: UnwindSafe,
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<'data, I> IntoParallelRefIterator<'data> for I where
I: 'data + ?Sized,
&'data I: IntoParallelIterator,
impl<'data, I> IntoParallelRefIterator<'data> for I where
I: 'data + ?Sized,
&'data I: IntoParallelIterator,
type Iter = <&'data I as IntoParallelIterator>::Iter
type Iter = <&'data I as IntoParallelIterator>::Iter
The type of the parallel iterator that will be returned.
type Item = <&'data I as IntoParallelIterator>::Item
type Item = <&'data I as IntoParallelIterator>::Item
The type of item that the parallel iterator will produce.
This will typically be an &'data T
reference type. Read more
sourcefn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter
fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter
Converts self
into a parallel iterator. Read more
sourceimpl<'data, I> IntoParallelRefMutIterator<'data> for I where
I: 'data + ?Sized,
&'data mut I: IntoParallelIterator,
impl<'data, I> IntoParallelRefMutIterator<'data> for I where
I: 'data + ?Sized,
&'data mut I: IntoParallelIterator,
type Iter = <&'data mut I as IntoParallelIterator>::Iter
type Iter = <&'data mut I as IntoParallelIterator>::Iter
The type of iterator that will be created.
type Item = <&'data mut I as IntoParallelIterator>::Item
type Item = <&'data mut I as IntoParallelIterator>::Item
The type of item that will be produced; this is typically an
&'data mut T
reference. Read more
sourcefn par_iter_mut(
&'data mut self
) -> <I as IntoParallelRefMutIterator<'data>>::Iter
fn par_iter_mut(
&'data mut self
) -> <I as IntoParallelRefMutIterator<'data>>::Iter
Creates the parallel iterator from self
. Read more