Skip to main content

Partial

Struct Partial 

Source
pub struct Partial<SS, SC = SeedOnly, S = RandomState>
where SS: SeedSize,
{ /* private fields */ }
Expand description

Map-or-bump function that assigns different numbers to some keys and None to other.

Can be used with any seed chooser (which specify a particular PHast variant): [ShiftOnlyWrapped], [ShiftSeedWrapped], SeedOnly, [SeedOnlyK].

See: Piotr Beling, Peter Sanders, PHast - Perfect Hashing made fast, 2025, https://arxiv.org/abs/2504.17918

Implementations§

Source§

impl<SS: SeedSize, SC: SeedChooser> Partial<SS, SC, ()>

Source

pub fn with_hashes_bps_conf_sc_be_u<'k, BE>( hashes: &'k mut [u64], seed_size: SS, conf: Conf, seed_chooser: SC, bucket_evaluator: BE, ) -> (Self, usize)

Source

pub fn with_hashes_bps_conf_bs_threads_sc_be_u<'k, BE>( hashes: &'k mut [u64], seed_size: SS, conf: Conf, threads_num: usize, seed_chooser: SC, bucket_evaluator: BE, ) -> (Self, usize)
where BE: BucketToActivateEvaluator + Sync, SC: Sync, BE::Value: Send,

Source

pub fn with_hashes_bps_conf_sc_be<'k, BE>( hashes: &'k mut [u64], seed_size: SS, conf: Conf, seed_chooser: SC, bucket_evaluator: BE, ) -> Self

Source

pub fn with_hashes_bps_conf_bs_threads_sc_be<'k, BE>( hashes: &'k mut [u64], seed_size: SS, conf: Conf, threads_num: usize, seed_chooser: SC, bucket_evaluator: BE, ) -> Self
where BE: BucketToActivateEvaluator + Sync, SC: Sync, BE::Value: Send,

Source

pub fn with_hashes_p_sc_be_u<'k, BE>( hashes: &'k mut [u64], params: &Params<SS>, seed_chooser: SC, bucket_evaluator: BE, ) -> (Self, usize)

Source

pub fn with_hashes_p_threads_sc_be_u<'k, BE>( hashes: &'k mut [u64], params: &Params<SS>, threads_num: usize, seed_chooser: SC, bucket_evaluator: BE, ) -> (Self, usize)
where BE: BucketToActivateEvaluator + Sync, SC: Sync, BE::Value: Send,

Source

pub fn with_hashes_p_sc_be<'k, BE>( hashes: &'k mut [u64], params: &Params<SS>, seed_chooser: SC, bucket_evaluator: BE, ) -> Self

Source

pub fn with_hashes_p_threads_sc_be<'k, BE>( hashes: &'k mut [u64], params: &Params<SS>, threads_num: usize, seed_chooser: SC, bucket_evaluator: BE, ) -> Self
where BE: BucketToActivateEvaluator + Sync, SC: Sync, BE::Value: Send,

Source

pub fn with_hashes_p_sc_u<'k, BE>( hashes: &'k mut [u64], params: &Params<SS>, seed_chooser: SC, ) -> (Self, usize)

Source

pub fn with_hashes_p_threads_sc_u<'k, BE>( hashes: &'k mut [u64], params: &Params<SS>, threads_num: usize, seed_chooser: SC, ) -> (Self, usize)
where BE: BucketToActivateEvaluator + Sync, SC: Sync, BE::Value: Send,

Source

pub fn with_hashes_p_sc<'k>( hashes: &'k mut [u64], params: &Params<SS>, seed_chooser: SC, ) -> Self

Source

pub fn with_hashes_p_threads_sc<'k>( hashes: &'k mut [u64], params: &Params<SS>, threads_num: usize, seed_chooser: SC, ) -> Self
where SC: Sync,

Source§

impl<SS: SeedSize, SC: SeedChooser, S> Partial<SS, SC, S>

Source

pub fn get_for_hash(&self, key_hash: u64) -> Option<usize>

Returns value assigned to the given key hash or None.

Source§

impl<SS: SeedSize, SC: SeedChooser, S> Partial<SS, SC, S>

Source

pub fn minimal_output_range(&self, num_of_keys: u32) -> usize

Returns output range of minimal (perfect or k-perfect) function for given number of keys, i.e. 1 + maximum value that minimal function can return.

Source

pub fn output_range(&self) -> usize

Returns output range of self, i.e. 1 + maximum value that self can return.

Source§

impl<SS: SeedSize, SC: SeedChooser, S: BuildHasher> Partial<SS, SC, S>

Source

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

Returns value assigned to the given key or None.

The returned value is in the range from 0 (inclusive) to the number of elements in the input key collection (exclusive). key must come from the input key collection given during construction.

Source

pub fn with_keys_p_hash_sc_be_u<'k, K, BE>( keys: impl Iterator<Item = K>, params: &Params<SS>, hasher: S, seed_chooser: SC, bucket_evaluator: BE, ) -> (Self, usize)

Returns Partial function and number of keys with unassigned values for given keys, using a single thread and given parameters.

Trait Implementations§

Source§

impl<SC, SS: SeedSize, S> GetSize for Partial<SS, SC, S>

Source§

const USES_DYN_MEM: bool = true

true if and only if the variables of this type can use dynamic (heap) memory.
Source§

fn size_bytes_dyn(&self) -> usize

Returns approximate number of bytes occupied by dynamic (heap) part of self. Same as self.size_bytes() - std::mem::size_of_val(self).
Source§

fn size_bytes_content_dyn(&self) -> usize

Returns approximate number of bytes occupied by dynamic (heap) part of self content. It usually equals to size_bytes_dyn(). However, sometimes it is smaller by the amount of memory reserved but not yet used (e.g., size_bytes_content_dyn() only takes into account the length of the vector and not its capacity).
Source§

fn size_bytes(&self) -> usize

Returns approximate, total (including heap memory) number of bytes occupied by self.

Auto Trait Implementations§

§

impl<SS, SC, S> Freeze for Partial<SS, SC, S>
where S: Freeze, SC: Freeze, SS: Freeze,

§

impl<SS, SC, S> RefUnwindSafe for Partial<SS, SC, S>

§

impl<SS, SC, S> Send for Partial<SS, SC, S>
where S: Send, SC: Send, SS: Send,

§

impl<SS, SC, S> Sync for Partial<SS, SC, S>
where S: Sync, SC: Sync,

§

impl<SS, SC, S> Unpin for Partial<SS, SC, S>
where S: Unpin, SC: Unpin, SS: Unpin,

§

impl<SS, SC, S> UnsafeUnpin for Partial<SS, SC, S>
where S: UnsafeUnpin, SC: UnsafeUnpin, SS: UnsafeUnpin,

§

impl<SS, SC, S> UnwindSafe for Partial<SS, SC, S>

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> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

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.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V