pub struct KevySet<K>(/* private fields */);Expand description
HashSet-shaped wrapper over KevyMap<K, ()>.
Carries the same per-shard / single-trust-domain assumptions; differs from
std::HashSet only by hashing through KevyHash (one-call inlinable)
and exposing the underlying KevyMap’s bucket-address API via
KevySet::as_map for callers that want prefetch.
Implementations§
Source§impl<K> KevySet<K>
impl<K> KevySet<K>
Sourcepub fn with_capacity(cap_hint: usize) -> Self
pub fn with_capacity(cap_hint: usize) -> Self
Construct a set sized for cap_hint members without growing.
Sourcepub fn iter_from_slot(&self, start: usize) -> impl Iterator<Item = &K>
pub fn iter_from_slot(&self, start: usize) -> impl Iterator<Item = &K>
Borrow the underlying map (gives access to the bucket-addr / prefetch
API).
An iterator that begins at slot start and wraps once around the whole
table. Take the first element for an arbitrary member in O(1) expected
time — the pattern SPOP and SRANDMEMBER need, and the one Redis’s
dictGetRandomKey uses.
Not perfectly uniform: a member sitting after a long run of empty slots
is likelier to be picked than one in a dense cluster. Redis has the same
bias for the same reason, and the contract is “arbitrary”, not “uniform”.
What it is NOT is the identical member every single time, which is what
iter().next() gives you.
Trait Implementations§
Source§impl<K: KevyHash + Eq> Extend<K> for KevySet<K>
impl<K: KevyHash + Eq> Extend<K> for KevySet<K>
Source§fn extend<I: IntoIterator<Item = K>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = K>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)