IOSS 2.0

Public Member Functions | Protected Attributes | Static Private Member Functions | List of all members
tsl::rh::power_of_two_growth_policy< GrowthFactor > Class Template Reference

`#include <robin_growth_policy.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 noexcept
std::size_t | next_bucket_count () const
std::size_t | max_bucket_count () const
void | clear () noexcept

## Protected Attributes
std::size_t | m_mask

## 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)

## Detailed Description

### template<std::size_t GrowthFactor>
class tsl::rh::power_of_two_growth_policy< GrowthFactor >

Grow the hash table by a factor of GrowthFactor keeping the bucket count to a power of two. It allows the table to use a mask operation instead of a modulo operation to map a hash to a bucket.

GrowthFactor must be a power of two >= 2.

## Constructor & Destructor Documentation

## ◆ power_of_two_growth_policy()

template<std::size_t GrowthFactor>

tsl::rh::power_of_two_growth_policy< GrowthFactor >::power_of_two_growth_policy | ( | std::size_t & | min_bucket_count_in_out | ) |
| inline explicit

Called on the hash table creation and on rehash. The number of buckets for the table is passed in parameter. This number is a minimum, the policy may update this value with a higher value if needed (but not lower).

If 0 is given, min_bucket_count_in_out must still be 0 after the policy creation and bucket_for_hash must always return 0 in this case.

## Member Function Documentation

## ◆ bucket_for_hash()

template<std::size_t GrowthFactor>

std::size_t tsl::rh::power_of_two_growth_policy< GrowthFactor >::bucket_for_hash | ( | std::size_t | hash | ) | const
| inline noexcept

Return the bucket [0, bucket_count()) to which the hash belongs. If bucket_count() is 0, it must always return 0.

## ◆ clear()

template<std::size_t GrowthFactor>

void tsl::rh::power_of_two_growth_policy< GrowthFactor >::clear | ( |  | ) |
| inline noexcept

Reset the growth policy as if it was created with a bucket count of 0. After a clear, the policy must always return 0 when bucket_for_hash is called.

## ◆ is_power_of_two()

template<std::size_t GrowthFactor>

static constexpr bool tsl::rh::power_of_two_growth_policy< GrowthFactor >::is_power_of_two | ( | std::size_t | value | ) |
| inline static private

## ◆ max_bucket_count()

template<std::size_t GrowthFactor>

std::size_t tsl::rh::power_of_two_growth_policy< GrowthFactor >::max_bucket_count | ( |  | ) | const
| inline

Return the maximum number of buckets supported by the policy.

## ◆ next_bucket_count()

template<std::size_t GrowthFactor>

std::size_t tsl::rh::power_of_two_growth_policy< GrowthFactor >::next_bucket_count | ( |  | ) | const
| inline

Return the number of buckets that should be used on next growth.

## ◆ round_up_to_power_of_two()

template<std::size_t GrowthFactor>

static std::size_t tsl::rh::power_of_two_growth_policy< GrowthFactor >::round_up_to_power_of_two | ( | std::size_t | value | ) |
| inline static private

## Member Data Documentation

## ◆ m_mask

template<std::size_t GrowthFactor>

std::size_t tsl::rh::power_of_two_growth_policy< GrowthFactor >::m_mask
| protected

The documentation for this class was generated from the following file:

- src/hash/robin_growth_policy.h