88#ifndef __ADS_MinimalPerfectHash
89 #define __ADS_MinimalPerfectHash
107#include <string_view>
108#include <type_traits>
123template<
class T ,
class H = DefaultHash< T > >
162 double alpha = 0.99 , std::uint64_t seed = 1 ,
184 [[nodiscard]] std::size_t
size(
void )
const;
187 [[nodiscard]]
bool empty(
void )
const;
190 [[nodiscard]] std::size_t
bits(
void )
const;
193 [[nodiscard]] std::size_t
buckets(
void )
const;
196 [[nodiscard]] std::size_t
trials(
void )
const;
201 static constexpr std::string_view
persistName =
"MinimalPerfectHash";
204 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
205 return( detail::persistMix( {
sizeof( T ) } ) );
215 static constexpr std::size_t kMaxTrials = 100;
216 static constexpr std::uint64_t kMaxPilot = std::uint64_t( 1 ) << 24;
219 [[nodiscard]] std::uint64_t base(
const T & k )
const;
222 [[nodiscard]] std::size_t bucket( std::uint64_t h )
const;
225 [[nodiscard]] std::size_t place( std::uint64_t h2 , std::uint64_t k )
const;
228 [[nodiscard]] std::uint64_t pilot( std::size_t b )
const;
232 bool build(
const std::vector< std::uint64_t > & B );
234 std::uint64_t f_seed;
237 std::size_t f_dense = 0;
238 std::size_t f_sparse = 0;
241 std::vector< std::uint64_t , MappableAllocator< std::uint64_t > > f_P;
242 std::vector< std::uint32_t > f_free;
243 std::size_t f_trials = 0;
256#include "ADS/dictionary/impl/MinimalPerfectHash.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The engineered hash functions of ADS, beyond the book [see HashFunctions.h for those of section 7....
A file mapped in memory, shared by the structures that are read from it in place [see Persistence....
bool empty(void) const
true if there are no keys
std::size_t operator()(const T &k) const
the value of , in ; some value in it for a key out of
std::size_t size(void) const
the number of keys
MinimalPerfectHash(void)
the function of no key
Definition MinimalPerfectHash.h:130
std::size_t trials(void) const
the seeds drawn by the build
T Key
the type of the keys
Definition MinimalPerfectHash.h:132
std::size_t bits(void) const
the bits of the function: the pilots, the free places and the sizes
static constexpr std::uint64_t persistTag(void)
the parameters of the layout, in a file
Definition MinimalPerfectHash.h:204
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition MinimalPerfectHash.h:201
MinimalPerfectHash(const std::vector< T > &keys, double lambda=5, double alpha=0.99, std::uint64_t seed=1, H h=H())
the function of the distinct keys, with keys per bucket on average and the load of the table
std::size_t buckets(void) const
the number of buckets
constexpr int lambda(Word x)
the place of the leading 1 of ,