Grow the map by a factor of two keeping bucket_count to a power of two. It allows the map to use a mask operation instead of a modulo operation to map a hash to a bucket.
Definition at line 73 of file hopscotch_hash.h.
#include <hopscotch_hash.h>
Public Member Functions | |
power_of_two_growth_policy (std::size_t &min_bucket_count_in_out) | |
std::size_t | bucket_for_hash (std::size_t hash) const |
std::size_t | next_bucket_count () const |
std::size_t | max_bucket_count () const |
Static Private Member Functions | |
static std::size_t | round_up_to_power_of_two (std::size_t value) |
static constexpr bool | is_power_of_two (std::size_t value) |
Private Attributes | |
std::size_t | m_mask |
Static Private Attributes | |
static const std::size_t | MIN_BUCKETS_SIZE = 2 |
|
inline |
Called on map creation and rehash. The number of buckets requested is passed by parameter. This number is a minimum, the policy may update this value with a higher value if needed.
Definition at line 79 of file hopscotch_hash.h.
|
inline |
Return the bucket [0, bucket_count()) to which the hash belongs.
Definition at line 95 of file hopscotch_hash.h.
|
inlinestaticconstexprprivate |
Definition at line 135 of file hopscotch_hash.h.
|
inline |
Return the maximum number of buckets supported by the policy.
Definition at line 113 of file hopscotch_hash.h.
|
inline |
Return the bucket count to uses when the bucket array grows on rehash.
Definition at line 102 of file hopscotch_hash.h.
|
inlinestaticprivate |
Definition at line 118 of file hopscotch_hash.h.
|
private |
Definition at line 142 of file hopscotch_hash.h.
|
staticprivate |
Definition at line 140 of file hopscotch_hash.h.