carl  24.04
Computer ARithmetic Library
carl::pool::RehashPolicy Class Reference

Mimics stdlibs default rehash policy for hashtables. More...

#include <PoolHelper.h>

Public Member Functions

 RehashPolicy (float maxLoadFactor=0.95f, float growthFactor=2.f)
 
std::size_t numBucketsFor (std::size_t numElements) const
 
std::pair< bool, std::size_t > needRehash (std::size_t numBuckets, std::size_t numElements) const
 

Private Attributes

float mMaxLoadFactor
 
float mGrowthFactor
 
std::size_t mNextResize
 

Static Private Attributes

static const int numPrimes = sizeof(unsigned long) != 8 ? 256 : 256 + 48
 
static const unsigned long primes [256+48+1]
 

Detailed Description

Mimics stdlibs default rehash policy for hashtables.

See https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.1/hashtable-source.html

Definition at line 15 of file PoolHelper.h.

Constructor & Destructor Documentation

◆ RehashPolicy()

carl::pool::RehashPolicy::RehashPolicy ( float  maxLoadFactor = 0.95f,
float  growthFactor = 2.f 
)
inline

Definition at line 24 of file PoolHelper.h.

Member Function Documentation

◆ needRehash()

std::pair< bool, std::size_t > carl::pool::RehashPolicy::needRehash ( std::size_t  numBuckets,
std::size_t  numElements 
) const

Definition at line 14 of file PoolHelper.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numBucketsFor()

std::size_t carl::pool::RehashPolicy::numBucketsFor ( std::size_t  numElements) const

Definition at line 7 of file PoolHelper.cpp.

Here is the call graph for this function:

Field Documentation

◆ mGrowthFactor

float carl::pool::RehashPolicy::mGrowthFactor
private

Definition at line 20 of file PoolHelper.h.

◆ mMaxLoadFactor

float carl::pool::RehashPolicy::mMaxLoadFactor
private

Definition at line 19 of file PoolHelper.h.

◆ mNextResize

std::size_t carl::pool::RehashPolicy::mNextResize
mutableprivate

Definition at line 21 of file PoolHelper.h.

◆ numPrimes

const int carl::pool::RehashPolicy::numPrimes = sizeof(unsigned long) != 8 ? 256 : 256 + 48
staticprivate

Definition at line 16 of file PoolHelper.h.

◆ primes

const unsigned long carl::pool::RehashPolicy::primes
staticprivate

Definition at line 17 of file PoolHelper.h.


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