maglev

Trait ConsistentHasher

Source
pub trait ConsistentHasher<N: Sized> {
    // Required methods
    fn nodes(&self) -> &[N];
    fn capacity(&self) -> usize;
    fn get<Q>(&self, key: &Q) -> Option<&N>
       where Q: Hash + Eq + ?Sized;
}
Expand description

Consistent hasher is a special kind of hashing such that when a hash table is resized, only K/n keys need to be remapped on average, where K is the number of keys, and n is the number of slots.

Required Methods§

Source

fn nodes(&self) -> &[N]

Returns all nodes in arbitrary order.

Source

fn capacity(&self) -> usize

Returns the number of slots in the lookup table.

Source

fn get<Q>(&self, key: &Q) -> Option<&N>
where Q: Hash + Eq + ?Sized,

Returns a reference to the node corresponding to the key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<N, S> ConsistentHasher<N> for Maglev<N, S>
where N: Hash + Eq, S: BuildHasher,