ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
HashFunctions.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File HashFunctions.h --------------------------*/
3/*--------------------------------------------------------------------------*/
60/*--------------------------------------------------------------------------*/
61/*----------------------------- DEFINITIONS --------------------------------*/
62/*--------------------------------------------------------------------------*/
63
64#ifndef __ADS_HashFunctions
65 #define __ADS_HashFunctions
66/* self-identification: #endif constant */
67
68/*--------------------------------------------------------------------------*/
69/*------------------------------ INCLUDES ----------------------------------*/
70/*--------------------------------------------------------------------------*/
71
72#include "ADS/Contract.h"
73
74#include <cmath>
75#include <cstddef>
76#include <cstdint>
77#include <limits>
78#include <string_view>
79
80/*--------------------------------------------------------------------------*/
81/*--------------------------- NAMESPACE ------------------------------------*/
82/*--------------------------------------------------------------------------*/
83
84namespace ADS
85{
86
87/*--------------------------------------------------------------------------*/
88/*----------------------------- HASH FUNCTIONS -----------------------------*/
89/*--------------------------------------------------------------------------*/
90
93unsigned bin_bit( std::string_view k , std::size_t j );
94
98std::uint64_t int_bin( std::string_view k );
99
116std::uint64_t hash_extraction( std::string_view k , int p , std::size_t s );
117
133std::uint64_t hash_xor( std::string_view k , int p );
134
159std::uint64_t hash_division( std::string_view k , std::uint64_t m ,
160 std::uint64_t base = 256 ,
161 std::uint64_t seed = 0 );
162
170std::uint64_t hash_multiplication( std::uint64_t i , std::uint64_t m ,
171 long double C = ( std::sqrt( 5.0L ) - 1 ) /
172 2 );
173
193std::uint64_t hash_fibonacci( std::uint64_t i , int p );
194
210std::uint64_t hash_midsquare( std::uint64_t i , int p );
211
212/*--------------------------------------------------------------------------*/
213
214} // end( namespace ADS )
215
216/*--------------------------------------------------------------------------*/
217/*-------------------------- IMPLEMENTATION --------------------------------*/
218/*--------------------------------------------------------------------------*/
219
220#include "ADS/dictionary/impl/HashFunctions.tpp"
221
222/*--------------------------------------------------------------------------*/
223
224#endif /* HashFunctions.h included */
225
226/*--------------------------------------------------------------------------*/
227/*------------------------ End File HashFunctions.h ------------------------*/
228/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
std::uint64_t hash_multiplication(std::uint64_t i, std::uint64_t m, long double C=(std::sqrt(5.0L) - 1)/2)
the multiplication in floating point, the formula of the book, : exact only while keeps enough digit...
unsigned bin_bit(std::string_view k, std::size_t j)
the bit of place of , counted from the left; 0 past the end
std::uint64_t int_bin(std::string_view k)
of a key of at most 8 characters
std::uint64_t hash_division(std::string_view k, std::uint64_t m, std::uint64_t base=256, std::uint64_t seed=0)
the division by the rule of Horner in the given base, each character being a digit,...
std::uint64_t hash_xor(std::string_view k, int p)
the XOR of the blocks of bits of , the last one padded with zeros on the right
std::uint64_t hash_midsquare(std::uint64_t i, int p)
the middle square: the bits in the middle of the 64 least significant ones of
std::uint64_t hash_extraction(std::string_view k, int p, std::size_t s)
the extraction: the bits of from the place on, counted from the left, as an integer in
std::uint64_t hash_fibonacci(std::uint64_t i, int p)
the multiplication with integers for , : the most significant bits of the 64 least significant ones ...
Definition ADT.h:96