pub struct ShardedSet<K, S = RandomState> { /* private fields */ }Implementations§
Source§impl<K, S> ShardedSet<K, S>
impl<K, S> ShardedSet<K, S>
pub fn new() -> Self
Sourcepub fn insert(&self, key: K) -> bool
pub fn insert(&self, key: K) -> bool
Whether key was newly inserted. Prefer extend_weighted for bulk work.
pub fn contains(&self, key: &K) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn extend_weighted(&self, items: impl IntoIterator<Item = (K, u64)>) -> u64
pub fn extend_weighted(&self, items: impl IntoIterator<Item = (K, u64)>) -> u64
Insert every key, taking each shard’s lock at most once. Returns the summed weight of the keys that were not already present.
Sourcepub fn try_extend_weighted<E>(
&self,
items: impl IntoIterator<Item = Result<(K, u64), E>>,
) -> Result<u64, E>
pub fn try_extend_weighted<E>( &self, items: impl IntoIterator<Item = Result<(K, u64), E>>, ) -> Result<u64, E>
Like Self::extend_weighted, but stops at the first Err and returns
it. Items are bucketed as they arrive, so the caller need not collect
them first.
pub fn extend(&self, keys: impl IntoIterator<Item = K>)
Sourcepub fn shard_lens(&self) -> Vec<usize>
pub fn shard_lens(&self) -> Vec<usize>
Number of keys in every shard, for distribution checks.
Trait Implementations§
Auto Trait Implementations§
impl<K, S = RandomState> !Freeze for ShardedSet<K, S>
impl<K, S> RefUnwindSafe for ShardedSet<K, S>
impl<K, S> Send for ShardedSet<K, S>
impl<K, S> Sync for ShardedSet<K, S>
impl<K, S> Unpin for ShardedSet<K, S>
impl<K, S> UnsafeUnpin for ShardedSet<K, S>
impl<K, S> UnwindSafe for ShardedSet<K, S>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreCreates a shared type from an unshared type.