pub struct Prime { /* private fields */ }Expand description
Grow by stepping through a fixed table of primes and map with a modulo.
A modulo by a compile-time-unknown prime is still fast here because the
table is small and the index selects the divisor. This policy spreads values
better than PowerOfTwo when the hash is poor.
Trait Implementations§
Source§impl GrowthPolicy for Prime
impl GrowthPolicy for Prime
Source§fn new(min_bucket_count: usize) -> Result<(Self, usize), LengthError>
fn new(min_bucket_count: usize) -> Result<(Self, usize), LengthError>
Build a policy for at least
min_bucket_count buckets. Read moreSource§fn bucket_for_hash(&self, hash: usize) -> usize
fn bucket_for_hash(&self, hash: usize) -> usize
Map
hash to a bucket in [0, bucket_count).Source§fn next_bucket_count(&self) -> Result<usize, LengthError>
fn next_bucket_count(&self) -> Result<usize, LengthError>
The bucket count to use on the next growth. Read more
Source§fn max_bucket_count(&self) -> usize
fn max_bucket_count(&self) -> usize
The largest bucket count the policy can represent.
Source§fn is_power_of_two() -> bool
fn is_power_of_two() -> bool
Whether this policy keeps the bucket count a power of two. Read more
Auto Trait Implementations§
impl Freeze for Prime
impl RefUnwindSafe for Prime
impl Send for Prime
impl Sync for Prime
impl Unpin for Prime
impl UnsafeUnpin for Prime
impl UnwindSafe for Prime
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
Mutably borrows from an owned value. Read more