Expand description
Growth policies that map a hash to a bucket and decide the next table size.
A policy owns the current bucket count and translates a hash into a bucket index. Three strategies are provided:
PowerOfTwokeeps the bucket count a power of two and maps with a mask. Fast, and the default.Modgrows by a rational factor and maps with a modulo. Useful for slower growth.Primeuses a fixed table of primes. It spreads values better when the hash function is poor, such as an identity hash of pointers.
Each policy is constructed from a minimum bucket count. The policy may round
that value up and reports the value it settled on. A request above the
policy maximum returns LengthError.
Structs§
- Length
Error - The requested bucket count exceeds what a growth policy can represent.
- Mod
- Grow by the rational factor
NUM / DENand map with a modulo. - Power
OfTwo - Grow by a power-of-two factor and map with a mask.
- Prime
- Grow by stepping through a fixed table of primes and map with a modulo.
Constants§
- PRIMES_
TABLE - The prime table used by
Prime. Ascending, 40 entries.
Traits§
- Growth
Policy - Strategy for sizing the bucket array and mapping a hash to a bucket.