Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
hash_dry_detail Namespace Reference

Functions

template<class Bucket >
size_t checked_table_len (const size_t len)
 Checks that the bytes of a table of buckets fit in a size_t.
 
template<class Bucket >
size_t prime_table_len (const size_t len)
 The length of a table for a request of len buckets: the next prime.
 
template<class Bucket >
void free_bucket_not_taken (Bucket *bucket) noexcept
 Frees a bucket that a hash table of lists was given and did not take.
 
template<class Cmp >
void swap_compare (Cmp &a, Cmp &b) noexcept
 Swaps the comparators of two hash tables.
 

Function Documentation

◆ checked_table_len()

template<class Bucket >
size_t hash_dry_detail::checked_table_len ( const size_t  len)
inline

Checks that the bytes of a table of buckets fit in a size_t.

For a count of buckets whose bytes do not fit, what new[] asks of the allocator depends on the compiler: some ask for the largest size_t, which under a sanitizer ends the program.

Template Parameters
Bucketthe type of the buckets of the table.
Parameters
[in]lenthe count of buckets.
Returns
len.
Exceptions
std::overflow_errorif the bytes of len buckets do not fit in a size_t.

Definition at line 82 of file hashDry.H.

References ah_overflow_error_if.

◆ prime_table_len()

template<class Bucket >
size_t hash_dry_detail::prime_table_len ( const size_t  len)
inline

The length of a table for a request of len buckets: the next prime.

The request is checked before it is taken to a prime, which past the table of primes is searched by trial division, and the prime after it.

Template Parameters
Bucketthe type of the buckets of the table.
Parameters
[in]lenthe buckets asked for.
Returns
The first prime that is len or more.
Exceptions
std::overflow_errorif the bytes of len buckets, or of that prime, do not fit in a size_t.

Definition at line 102 of file hashDry.H.

References Primes::next_prime().