pub struct ShardedHashMap<K, V, S = FxBuildHasher>where
K: Eq + Hash + Clone + Send + Sync,
V: Clone + Send + Sync,
S: BuildHasher + Clone + Send + Sync,{ /* private fields */ }Expand description
Sharded concurrent HashMap (synchronous).
Cloning the map is cheap (Arc handles + atomic length).
Implementations§
Source§impl<K, V> ShardedHashMap<K, V, FxBuildHasher>
impl<K, V> ShardedHashMap<K, V, FxBuildHasher>
Source§impl<K, V, S> ShardedHashMap<K, V, S>
impl<K, V, S> ShardedHashMap<K, V, S>
Sourcepub fn with_shards_and_hasher(shard_count: usize, hasher: S) -> Self
pub fn with_shards_and_hasher(shard_count: usize, hasher: S) -> Self
Create with explicit hasher (non-zero shard count fallback).
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Current configured shard slots.
Sourcepub fn initialized_shards(&self) -> usize
pub fn initialized_shards(&self) -> usize
Number of shards actually initialized (allocated).
Sourcepub fn iter(&self) -> impl Iterator<Item = (K, V)>
pub fn iter(&self) -> impl Iterator<Item = (K, V)>
Snapshot iteration over (K,V) clones.
Semantics:
- Collects a list of initialized shard Arcs first (short critical section).
- Each shard is read-locked independently; values cloned.
- Not a live iterator: modifications after a shard snapshot are not reflected.
- If
rayonenabled, internal flattening per-shard happens in parallel for speed.
Cost:
- O(N) cloning cost for visited entries.
- Temporary Vec allocations proportional to initialized shard count (and item copies).
§Returns
impl Iterator<Item = (K, V)>: iterator over cloned key/value pairs.
Trait Implementations§
Source§impl<K, V, S> Clone for ShardedHashMap<K, V, S>
impl<K, V, S> Clone for ShardedHashMap<K, V, S>
Source§fn clone(&self) -> ShardedHashMap<K, V, S>
fn clone(&self) -> ShardedHashMap<K, V, S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'de, K, V, S> Deserialize<'de> for ShardedHashMap<K, V, S>where
K: Eq + Hash + Clone + Send + Sync + Deserialize<'de>,
V: Clone + Send + Sync + Deserialize<'de>,
S: BuildHasher + Clone + Send + Sync + Default,
Available on crate feature serde only.
impl<'de, K, V, S> Deserialize<'de> for ShardedHashMap<K, V, S>where
K: Eq + Hash + Clone + Send + Sync + Deserialize<'de>,
V: Clone + Send + Sync + Deserialize<'de>,
S: BuildHasher + Clone + Send + Sync + Default,
Available on crate feature
serde only.Source§fn 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
Source§impl<K, V, S> Serialize for ShardedHashMap<K, V, S>
Available on crate feature serde only.
impl<K, V, S> Serialize for ShardedHashMap<K, V, S>
Available on crate feature
serde only.Auto Trait Implementations§
impl<K, V, S> Freeze for ShardedHashMap<K, V, S>where
S: Freeze,
impl<K, V, S> RefUnwindSafe for ShardedHashMap<K, V, S>where
S: RefUnwindSafe,
impl<K, V, S> Send for ShardedHashMap<K, V, S>
impl<K, V, S> Sync for ShardedHashMap<K, V, S>
impl<K, V, S> Unpin for ShardedHashMap<K, V, S>where
S: Unpin,
impl<K, V, S> UnwindSafe for ShardedHashMap<K, V, S>where
S: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more