Mphf

Struct Mphf 

Source
pub struct Mphf<const B: usize = 32, const S: usize = 8, ST: PrimInt + Unsigned = u8, H: Hasher + Default = WyHash> { /* private fields */ }
Expand description

A Minimal Perfect Hash Function (MPHF).

Template parameters:

  • B: group size in bits in [1..64] range, default 32 bits.
  • S: defines maximum seed value to try (2^S) in [0..16] range, default 8.
  • ST: seed type (unsigned integer), default u8.
  • H: hasher used to hash keys, default WyHash.

Implementations§

Source§

impl<const B: usize, const S: usize, ST: PrimInt + Unsigned, H: Hasher + Default> Mphf<B, S, ST, H>

Source

pub fn from_slice<K: Hash>(keys: &[K], gamma: f32) -> Result<Self, MphfError>

Initializes Mphf using slice of keys and parameter gamma.

Source

pub fn get<K: Hash + ?Sized>(&self, key: &K) -> Option<usize>

Returns the index associated with key, within 0 to the key collection size (exclusive). If key was not in the initial collection, returns None or an arbitrary value from the range.

Source

pub fn size(&self) -> usize

Returns the total number of bytes occupied by Mphf

Trait Implementations§

Source§

impl<const B: usize, const S: usize, ST: Default + PrimInt + Unsigned, H: Default + Hasher + Default> Default for Mphf<B, S, ST, H>

Source§

fn default() -> Mphf<B, S, ST, H>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const B: usize, const S: usize, ST, H> Freeze for Mphf<B, S, ST, H>

§

impl<const B: usize, const S: usize, ST, H> RefUnwindSafe for Mphf<B, S, ST, H>

§

impl<const B: usize, const S: usize, ST, H> Send for Mphf<B, S, ST, H>
where H: Send, ST: Send,

§

impl<const B: usize, const S: usize, ST, H> Sync for Mphf<B, S, ST, H>
where H: Sync, ST: Sync,

§

impl<const B: usize, const S: usize, ST, H> Unpin for Mphf<B, S, ST, H>
where H: Unpin,

§

impl<const B: usize, const S: usize, ST, H> UnwindSafe for Mphf<B, S, ST, H>
where H: UnwindSafe, ST: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.