ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
TableSize.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*---------------------------- File TableSize.h ----------------------------*/
3/*--------------------------------------------------------------------------*/
28/*--------------------------------------------------------------------------*/
29/*----------------------------- DEFINITIONS --------------------------------*/
30/*--------------------------------------------------------------------------*/
31
32#ifndef __ADS_TableSize
33 #define __ADS_TableSize
34/* self-identification: #endif constant */
35
36/*--------------------------------------------------------------------------*/
37/*------------------------------ INCLUDES ----------------------------------*/
38/*--------------------------------------------------------------------------*/
39
40#include "ADS/Contract.h"
41
42#include <algorithm>
43#include <concepts>
44#include <cstddef>
45
46/*--------------------------------------------------------------------------*/
47/*--------------------------- NAMESPACE ------------------------------------*/
48/*--------------------------------------------------------------------------*/
49
50namespace ADS
51{
52
53/*--------------------------------------------------------------------------*/
54/*-------------------------------- HELPERS ---------------------------------*/
55/*--------------------------------------------------------------------------*/
56
58bool is_prime( std::size_t n );
59
61std::size_t next_prime( std::size_t n );
62
65bool is_pow2( std::size_t n );
66
85std::size_t resized( std::size_t m , bool grow , std::size_t m0 );
86
95template< class H , class K >
96concept PlaceHash = requires( const H & h , const K & k , std::size_t m )
97{
98 { h.place( k , m ) } -> std::convertible_to< std::size_t >;
99 };
100
101/*--------------------------------------------------------------------------*/
102
103} // end( namespace ADS )
104
105/*--------------------------------------------------------------------------*/
106/*-------------------------- IMPLEMENTATION --------------------------------*/
107/*--------------------------------------------------------------------------*/
108
109#include "ADS/dictionary/impl/TableSize.tpp"
110
111/*--------------------------------------------------------------------------*/
112
113#endif /* TableSize.h included */
114
115/*--------------------------------------------------------------------------*/
116/*-------------------------- End File TableSize.h --------------------------*/
117/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a hash that maps a key straight to a place of a table of places by h.place( k , m ),...
Definition TableSize.h:96
bool is_pow2(std::size_t n)
true if is a power of two, i.e., and n & ( n - 1 ) is 0
std::size_t resized(std::size_t m, bool grow, std::size_t m0)
the size after a doubling, or after a halving down to
bool is_prime(std::size_t n)
true if is prime, by trial division up to
std::size_t next_prime(std::size_t n)
the smallest prime not smaller than , by trial divisions
Definition ADT.h:96