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, ()>
impl<SS: SeedSize, SC: SeedChooser> Partial<SS, SC, ()>
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)where
BE: BucketToActivateEvaluator,
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)
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,
) -> Selfwhere
BE: BucketToActivateEvaluator,
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
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)where
BE: BucketToActivateEvaluator,
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)
pub fn with_hashes_p_sc_be<'k, BE>(
hashes: &'k mut [u64],
params: &Params<SS>,
seed_chooser: SC,
bucket_evaluator: BE,
) -> Selfwhere
BE: BucketToActivateEvaluator,
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
pub fn with_hashes_p_sc_u<'k, BE>(
hashes: &'k mut [u64],
params: &Params<SS>,
seed_chooser: SC,
) -> (Self, usize)where
BE: BucketToActivateEvaluator,
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)
pub fn with_hashes_p_sc<'k>( hashes: &'k mut [u64], params: &Params<SS>, seed_chooser: SC, ) -> Self
pub fn with_hashes_p_threads_sc<'k>(
hashes: &'k mut [u64],
params: &Params<SS>,
threads_num: usize,
seed_chooser: SC,
) -> Selfwhere
SC: Sync,
Source§impl<SS: SeedSize, SC: SeedChooser, S> Partial<SS, SC, S>
impl<SS: SeedSize, SC: SeedChooser, S> Partial<SS, SC, S>
Sourcepub fn get_for_hash(&self, key_hash: u64) -> Option<usize>
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>
impl<SS: SeedSize, SC: SeedChooser, S> Partial<SS, SC, S>
Sourcepub fn minimal_output_range(&self, num_of_keys: u32) -> usize
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.
Sourcepub fn output_range(&self) -> usize
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>
impl<SS: SeedSize, SC: SeedChooser, S: BuildHasher> Partial<SS, SC, S>
Sourcepub fn get<K>(&self, key: &K) -> Option<usize>
pub fn get<K>(&self, key: &K) -> Option<usize>
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.
Sourcepub 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)where
K: Hash,
BE: BucketToActivateEvaluator,
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)where
K: Hash,
BE: BucketToActivateEvaluator,
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>
impl<SC, SS: SeedSize, S> GetSize for Partial<SS, SC, S>
Source§const USES_DYN_MEM: bool = true
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
fn size_bytes_dyn(&self) -> usize
self.
Same as self.size_bytes() - std::mem::size_of_val(self).Source§fn size_bytes_content_dyn(&self) -> usize
fn size_bytes_content_dyn(&self) -> usize
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
fn size_bytes(&self) -> usize
self.Auto Trait Implementations§
impl<SS, SC, S> Freeze for Partial<SS, SC, S>
impl<SS, SC, S> RefUnwindSafe for Partial<SS, SC, S>where
S: RefUnwindSafe,
SC: RefUnwindSafe,
SS: RefUnwindSafe,
<SS as SeedSize>::VecElement: RefUnwindSafe,
impl<SS, SC, S> Send for Partial<SS, SC, S>
impl<SS, SC, S> Sync for Partial<SS, SC, S>
impl<SS, SC, S> Unpin for Partial<SS, SC, S>
impl<SS, SC, S> UnsafeUnpin for Partial<SS, SC, S>
impl<SS, SC, S> UnwindSafe for Partial<SS, SC, 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
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
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>
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>
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