tudocomp
– The TU Dortmund Compression Framework
Hash.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <tudocomp/def.hpp>
3 #include <tudocomp/Algorithm.hpp>
4 #include <tudocomp/util.hpp>
7 // #include <tudocomp/util/hash/clhash.h>
8 // #include <tudocomp/util/hash/zobrist.h>
9 
10 namespace tdc {
11 
12  //TODO: can operator() be made to constexpr?
13 struct VignaHasher : public Algorithm { // http://xorshift.di.unimi.it/splitmix64.c
14  inline static Meta meta() {
15  Meta m("hash_function", "vigna", "Vigna's splitmix Hasher");
16  return m;
17  }
18  VignaHasher(Env&& env) : Algorithm(std::move(env)) {}
19  inline uint64_t operator()(uint64_t x) const {
20  x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
21  x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);
22  x = x ^ (x >> 31);
23  return x;
24  }
25 };
26 struct _VignaHasher { // http://xorshift.di.unimi.it/splitmix64.c
27  inline uint64_t operator()(uint64_t x) const {
28  x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
29  x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);
30  x = x ^ (x >> 31);
31  return x;
32  }
33 };
34 
35 struct KnuthHasher : public Algorithm { // http://xorshift.di.unimi.it/splitmix64.c
36  inline static Meta meta() {
37  Meta m("hash_function", "knuth", "Knuth's splitmix Hasher");
38  return m;
39  }
40  KnuthHasher(Env&& env) : Algorithm(std::move(env)) {}
41  size_t operator()(size_t key)
42  {
43  return key * 2654435769ULL;
44  }
45 };
46 
47 
48 struct MixHasher : public Algorithm { // https://gist.github.com/badboy/6267743
49  inline static Meta meta() {
50  Meta m("hash_function", "mixer", "MixHasher");
51  return m;
52  }
53  MixHasher(Env&& env) : Algorithm(std::move(env)) {}
54  size_t operator()(size_t key) const {
55  key = (~key) + (key << 21); // key = (key << 21) - key - 1;
56  key = key ^ (key >> 24);
57  key = (key + (key << 3)) + (key << 8); // key * 265
58  key = key ^ (key >> 14);
59  key = (key + (key << 2)) + (key << 4); // key * 21
60  key = key ^ (key >> 28);
61  key = key + (key << 31);
62  return key;
63  }
64 };
65 
66 struct NoopHasher : public Algorithm {
67  inline static Meta meta() {
68  Meta m("hash_function", "noop", "Identity");
69  return m;
70  }
71  NoopHasher(Env&& env) : Algorithm(std::move(env)) {}
72  size_t operator()(size_t key) const {
73  return key;
74  }
75 };
76 
77 
79 
80 struct SizeManagerPow2 : public Algorithm {
81  inline static Meta meta() {
82  Meta m("hash_manager", "pow", "Pow2 Hash Table Sizes");
83  return m;
84  }
86  void resize(const len_t) {
87  }
91  static inline len_t get_min_size(const len_t& hint) {
92  return 1ULL<<bits_hi(std::max<len_t>(hint,3UL));
93  }
98  static inline len_t mod_tablesize(const size_t& index, const len_t& tablesize, const size_t& , const size_t&) {
99  return index & (tablesize-1);
100  }
101 };
102 
103 
104 
105 struct SizeManagerDirect : public Algorithm {
106  inline static Meta meta() {
107  Meta m("hash_manager", "direct", "Direct Hash Table Sizes");
108  return m;
109  }
114  static inline len_t get_min_size(const len_t& hint) {
115  return std::max<len_t>(hint,3UL);
116  }
117  void resize(const len_t) {
118  }
119 
125  inline len_t mod_tablesize(const size_t, const len_t tablesize, const size_t key, const size_t probe) {
126  const __uint128_t v = (static_cast<uint64_t>(key + (static_cast<__uint128_t>(probe) << 64)/(tablesize))) * static_cast<__uint128_t>(tablesize);
127  const len_t ret = v >> 64;
128  DCHECK_LT(ret, tablesize);
129  return ret;
130  // return index % tablesize; // fallback
131  }
132 };
133 
134 struct SizeManagerNoob : public Algorithm {
135  inline static Meta meta() {
136  Meta m("hash_manager", "noob", "Classic Modulo Reduction");
137  return m;
138  }
143  static inline len_t get_min_size(const len_t& hint) {
144  return std::max<len_t>(hint,3UL);
145  }
146  void resize(const len_t) {
147  }
148 
152  inline len_t mod_tablesize(const size_t index, const len_t tablesize, const size_t , const size_t ) {
153  return index % tablesize; // fallback
154  }
155 };
156 
157 
158 struct SizeManagerPrime : public Algorithm {
159  inline static Meta meta() {
160  Meta m("hash_manager", "prime", "Prime Hash Table Sizes");
161  return m;
162  }
164 
165  static inline len_t get_min_size(const len_t& hint) {
166  return next_prime(hint);
167  }
168  void resize(const len_t) {
169  }
170  static inline len_t mod_tablesize(const size_t& index, const len_t& tablesize, const size_t& , const size_t&) {
171  //return (static_cast<uint64_t>(index)*static_cast<uint64_t>(tablesize)) >> 32;
172  return index % tablesize;
173  }
174  // From https://github.com/rockeet/nark-hashmap
175  // By rockeet
176  // GNU Affero General Public License
177  inline static size_t next_prime(size_t __n)
178  {
179  static const size_t primes[] =
180  {
181  5,11,19,37, 53ul, 97ul, 193ul, 389ul,
182  769ul, 1543ul, 3079ul, 6151ul, 12289ul,
183  24593ul, 49157ul, 98317ul, 196613ul, 393241ul,
184  786433ul, 1572869ul, 3145739ul, 6291469ul, 12582917ul,
185  25165843ul, 50331653ul, 100663319ul, 201326611ul, 402653189ul,
186  805306457ul, 1610612741ul, 3221225473ul, 4294967291ul,
187  /* 30 */ (size_t)8589934583ull,
188  /* 31 */ (size_t)17179869143ull,
189  /* 32 */ (size_t)34359738337ull,
190  /* 33 */ (size_t)68719476731ull,
191  /* 34 */ (size_t)137438953447ull,
192  /* 35 */ (size_t)274877906899ull,
193  /* 36 */ (size_t)549755813881ull,
194  /* 37 */ (size_t)1099511627689ull,
195  /* 38 */ (size_t)2199023255531ull,
196  /* 39 */ (size_t)4398046511093ull,
197  /* 40 */ (size_t)8796093022151ull,
198  /* 41 */ (size_t)17592186044399ull,
199  /* 42 */ (size_t)35184372088777ull,
200  /* 43 */ (size_t)70368744177643ull,
201  /* 44 */ (size_t)140737488355213ull,
202  /* 45 */ (size_t)281474976710597ull,
203  /* 46 */ (size_t)562949953421231ull,
204  /* 47 */ (size_t)1125899906842597ull,
205  /* 48 */ (size_t)2251799813685119ull,
206  /* 49 */ (size_t)4503599627370449ull,
207  /* 50 */ (size_t)9007199254740881ull,
208  /* 51 */ (size_t)18014398509481951ull,
209  /* 52 */ (size_t)36028797018963913ull,
210  /* 53 */ (size_t)72057594037927931ull,
211  /* 54 */ (size_t)144115188075855859ull,
212  /* 55 */ (size_t)288230376151711717ull,
213  /* 56 */ (size_t)576460752303423433ull,
214  /* 57 */ (size_t)1152921504606846883ull,
215  /* 58 */ (size_t)2305843009213693951ull,
216  /* 59 */ (size_t)4611686018427387847ull,
217  /* 60 */ (size_t)9223372036854775783ull,
218  /* 61 */ (size_t)18446744073709551557ull,
219  };
220  const size_t* __first = primes;
221  const size_t* __last = primes + sizeof(primes)/sizeof(primes[0]);
222  const size_t* pos = std::lower_bound(__first, __last, __n);
223  return pos == __last ? __last[-1] : *pos;
224  }
225 };
226 
228 
229 struct QuadraticProber : public Algorithm {
230  inline static Meta meta() {
231  Meta m("hash_prober", "quad", "Quadratic Prober");
232  return m;
233  }
235  template<class key_t>
236  static inline void init(const key_t&) {
237  }
244  template<class SizeManager>
245  static inline len_t get(const len_t& i, const len_t&, const len_t& init, const len_t&) {
246  return init+i*i;
247  }
248 };
249 
250 struct GaussProber : public Algorithm {
251  inline static Meta meta() {
252  Meta m("hash_prober", "gauss", "Gauss Prober");
253  return m;
254  }
255  GaussProber(Env&& env) : Algorithm(std::move(env)) {}
256  template<class key_t>
257  static inline void init(const key_t&) {
258  }
259  template<class SizeManager>
260  static inline len_t get(const len_t& i, const len_t& tablepos, const len_t&, const len_t&) {
261  return tablepos+i;
262  }
263 };
264 
265 
266 struct LinearProber : public Algorithm {
267  inline static Meta meta() {
268  Meta m("hash_prober", "linear", "Linear Prober");
269  return m;
270  }
272 
273  template<class key_t>
274  static inline void init(const key_t&) {
275  }
276  template<class SizeManager>
277  static inline len_t get(const len_t&, const len_t& tablepos, const len_t&, const len_t&) {
278  return tablepos+1;
279  }
280 };
281 
282 template<class SizeManager>
284  static inline len_t get(const size_t& hash_value, const len_t& max_value) {
285  return (1+(hash_value%(max_value-1))) | 1;
286  }
287 };
288 
289 
290 template<class key_t, class HashFcn>
292  HashFcn f;
293  size_t hash_value;
294  public:
295  inline void init(const key_t& key) {
296  hash_value = f(key);
297  }
298  template<class SizeManager>
299  inline len_t get(const len_t&, const len_t& tablepos, const len_t&, const len_t& max_value) const {
300  //return init+i*hash_value;
301  return tablepos+ _DoubleHashingProber<SizeManager>::get(hash_value, max_value); //( (1+(hash_value%(max_value-1)))|1);
302  }
303 };
304 
306 
308  public:
309  typedef uint64_t key_type;
310  private:
311  key_type m_val=0;
312  key_type m_len=0;
313  public:
314  inline static Meta meta() {
315  Meta m("hash_roll", "zbackup", "ZBackup Rolling Hash");
316  return m;
317  }
319  void operator+=(char c) {
320  m_val = (m_val << (sizeof(char)*sizeof(key_type))) + m_val + static_cast<key_type>(c); // % 18446744073709551557ULL;
321  m_len += m_len << 8;
322  }
323  key_type operator()() {
324  return (m_val+m_len) % (-1); //18446744073709551557ULL;
325  }
326  void clear() {
327  m_val=0;
328  m_len=0;
329  }
330 };
331 
333  public:
334  typedef uint64_t key_type;
335  private:
336  key_type m_val=0;
337  public:
338  inline static Meta meta() {
339  Meta m("hash_roll", "wordpack", "Wordpacking Rolling Hash");
340  return m;
341  }
343  void operator+=(char c) {
344  m_val = ((m_val + (m_val << 8)) + c);// % 138350580553ULL; // prime number between 2**63 and 2**64
345  }
346  key_type operator()() {
347  return m_val;
348  }
349  void clear() {
350  m_val=0;
351  }
352 };
353 
354 
355 template <class Key, class Value,
356  Value undef_id,
357  class HashFcn = MixHasher,
358  class EqualKey = std::equal_to<Key>,
359  class ProbeFcn = QuadraticProber,
361  >
362 class HashMap {
363  //static_assert(!std::is_same<ProbeFcn, QuadraticProber>::value || !std::is_same<SizeManager,SizeManagerPow2>::value, "Cannot use QuadraticProber with SizeManagerPow2");
364  public:
365  typedef Key key_t;
366  typedef Value value_t;
367  typedef std::pair<key_t,value_t> store_t;
368 
369  inline static Meta meta() {
370  Meta m("hash", "ctable", "Custom Hash Table");
371  return m;
372  }
373 
374 
375  EqualKey m_eq;
376  HashFcn m_h;
377  ProbeFcn m_probe;
378  SizeManager m_sizeman;
379  size_t m_size;
380  key_t* m_keys;
381  value_t* m_values;
382  len_t m_entries = 0;
383  float m_load_factor = 0.3f;
384  static constexpr value_t empty_val = undef_id;
385  static constexpr len_t initial_size = 4; // nark::__hsm_stl_next_prime(1)
387  size_t m_collisions = 0;
388  size_t m_old_size = 0;
389  size_t m_resizes = 0;
390  size_t m_specialresizes = 0;
391  )
392 
393  public:
394  IF_STATS(
395  size_t collisions() const { return m_collisions; }
396  void collect_stats(Env&) const {
397  StatPhase::log("collisions", collisions());
398  StatPhase::log("table size", table_size());
399  StatPhase::log("load factor", max_load_factor());
400  StatPhase::log("entries", entries());
401  StatPhase::log("resizes", m_resizes);
402  StatPhase::log("special resizes", m_specialresizes);
403  StatPhase::log("load ratio", entries()*100/table_size());
404  }
405  )
406  void max_load_factor(float z) {
407  m_load_factor = z;
408  }
409  float max_load_factor() const noexcept {
410  return m_load_factor;
411  }
412  const size_t m_n;
413  const size_t& m_remaining_characters;
414 
415  HashMap(Env&, const size_t n, const size_t& remaining_characters)
416  : m_h(create_env(HashFcn::meta()))
417  , m_probe(create_env(ProbeFcn::meta()))
418 // env.env_for_option("hash_prober"))
419  , m_sizeman(create_env(SizeManager::meta())) //env.env_for_option("hash_manager"))
420  , m_size(initial_size)
421  , m_keys((key_t*) malloc(sizeof(key_t) * initial_size))
422  , m_values((value_t*) malloc(sizeof(value_t) * initial_size))
423  , m_n(n)
424  , m_remaining_characters(remaining_characters)
425  {
426  for(size_t i = 0; i < m_size; ++i) m_values[i] = undef_id;
427  m_sizeman.resize(m_size);
428  }
429  template<class T>
430  void incorporate(T&& o, len_t newsize)
431  {
432  if(m_keys != nullptr) { free(m_keys); }
433  if(m_values != nullptr) { free(m_values); }
434 
435  m_keys = std::move(o.m_keys);
436  m_values = std::move(o.m_values);
437  m_size = std::move(o.m_size);
438  m_sizeman.resize(m_size);
439  m_entries = std::move(o.m_entries);
440  o.m_keys = nullptr;
441  o.m_values = nullptr;
442  IF_STATS(
443  m_collisions = ( o.m_collisions);
444  m_old_size = ( o.m_old_size);
445  m_resizes = ( o.m_resizes);
446  m_specialresizes = ( m_specialresizes);
447  )
448  reserve(newsize);
449  }
450 
453  if (m_guard) {
454  if(m_keys != nullptr) { free(m_keys); }
455  if(m_values != nullptr) { free(m_values); }
456  }
457  }
458  inline HashMap(HashMap&& other) = default;
459  inline HashMap& operator=(HashMap&& other) = default;
460 
461  void reserve(len_t hint) {
462  IF_STATS(++m_resizes);
463  const auto size = m_sizeman.get_min_size(hint);
464  if(m_entries > 0) {
465  const size_t oldsize = m_size;
466  m_size = size;
467  m_sizeman.resize(m_size);
468  key_t* keys = (key_t*) malloc(sizeof(key_t) * m_size);
469  value_t* values = (value_t*) malloc(sizeof(value_t) * m_size);
470  for(size_t i = 0; i < m_size; ++i) values[i] = undef_id;
471 // memset(values, 0, sizeof(value_t)*size);
472  std::swap(m_values,values);
473  std::swap(m_keys,keys);
474  m_entries=0;
475  for(len_t i = 0; i < oldsize; ++i) {
476  if(values[i] == empty_val) continue;
477  auto ret = insert(std::make_pair(std::move(keys[i]),std::move(values[i])));
478  DCHECK_EQ(ret.second, true); // no duplicates
479  }
480  free(keys);
481  free(values);
482  }
483  else {
484  m_size = size;
485  m_sizeman.resize(m_size);
486  m_values = (value_t*) realloc(m_values, sizeof(value_t) * m_size);
487  //memset(m_values, 0, sizeof(value_t)*size);
488  for(size_t i = 0; i < m_size; ++i) m_values[i] = undef_id;
489  m_keys = (key_t*) realloc(m_keys, sizeof(key_t) * m_size);
490  }
491  }
492 
493  class Iterator {
494  HashMap* m_table;
495  len_t m_offset;
496  public:
497  Iterator(HashMap* table, len_t offset)
498  : m_table(table), m_offset(offset)
499  {
500  }
501  bool operator==(const Iterator& o) const {
502  return m_table == o.m_table && m_offset = o.m_offset;
503  }
505  m_table = o.m_table;
506  m_offset = o.m_offset;
507  return *this;
508  }
509  const value_t& value() const {
510  return m_table->m_values[m_offset];
511  }
512  };
513 
514  inline len_t entries() const { return m_entries; }
515  inline len_t table_size() const { return m_size; }
516  inline len_t empty() const { return m_entries == 0; }
517 
518  std::pair<Iterator,bool> insert(std::pair<key_t,value_t>&& value) {
519  len_t i=0;
520 // const size_t _size = table_size()-1;
521  //const size_t _size = table_size();
522  DCHECK_NE(value.second, empty_val); // cannot insert the empty value
523  const size_t init_hashvalue = m_h(value.first);
524  size_t hash = m_sizeman.mod_tablesize(init_hashvalue, table_size(), init_hashvalue, i);
525  m_probe.init(value.first);
526  len_t tablepos = hash;
527  while(true) {
528  if(m_values[tablepos] == empty_val) {
529  m_keys[tablepos] = std::move(value.first);
530  m_values[tablepos] = std::move(value.second);
531  ++m_entries;
532  if(tdc_unlikely(table_size()*max_load_factor() < m_entries)) {
533  auto toinsert = std::make_pair(m_keys[tablepos], m_values[tablepos]);
534 
535  size_t expected_size =
536  std::is_same<SizeManager,SizeManagerDirect>::value ?
537  (m_entries + 3.0/2.0*lz78_expected_number_of_remaining_elements(entries(),m_n,m_remaining_characters))/0.95 :
538  (m_entries + lz78_expected_number_of_remaining_elements(entries(),m_n,m_remaining_characters))/0.95;
539  expected_size = std::max<size_t>(expected_size, table_size()*1.1);
540  if(expected_size < table_size()*2.0*0.95) {
541  max_load_factor(0.95f);
542  if(std::is_same<SizeManager,SizeManagerDirect>::value) {
543  reserve(expected_size);
544  } else {
545  reserve(expected_size); //(m_entries + lz78_expected_number_of_remaining_elements(entries(),m_n,m_remaining_characters))/0.95);
546  }
547 
548  IF_STATS(++m_specialresizes);
549  } else {
550  reserve((table_size()-1)<<1);
551  }
552  auto ret = insert(std::move(toinsert)); //rehashing invalidates the above computed hash!
553  DCHECK_EQ(ret.second, false); // it should now be inserted
554  return std::make_pair(ret.first, true);
555  }
556  return std::make_pair(Iterator(this,tablepos),true);
557  }
558  if(m_eq(m_keys[tablepos], value.first)) {
559  return std::make_pair(Iterator(this,tablepos), false);
560  }
561 #ifdef USE_KNUTH_ORDERED //we used the reverse ordered of knuth since we insert values in ascending order
562  if(m_keys[tablepos] > value.first) {
563  std::swap(value.first,m_keys[tablepos]); // put value into m_data[tablepos], kicking the stored value in the table out
564  std::swap(value.second,m_values[tablepos]);
565  hash = m_sizeman.mod_tablesize(init_hashvalue, table_size(), init_hashvalue, i);
566  m_probe.init(value.first);
567  }
568 
569 #endif
570  ++i; //collision
571  tablepos = m_sizeman.mod_tablesize(m_probe.template get<SizeManager>(i, tablepos, hash, table_size()), table_size(), init_hashvalue, i);
572  DCHECK_LT(i, table_size()) << "Hash table is full!";
573  IF_STATS(++m_collisions);
575  m_old_size = table_size();
576  if(m_old_size != table_size()) {
577  DVLOG(1) << "HashMap size " << table_size() << std::endl;
578  }))
579  }
580  }
581 
582 };
583 
584 
585 
586 
587 }
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
Iterator(HashMap *table, len_t offset)
Definition: Hash.hpp:497
static len_t get(const size_t &hash_value, const len_t &max_value)
Definition: Hash.hpp:284
const size_t & m_remaining_characters
Definition: Hash.hpp:413
size_t m_size
Definition: Hash.hpp:379
Provides meta information about an Algorithm.
Definition: Meta.hpp:34
static Meta meta()
Definition: Hash.hpp:230
static Meta meta()
Definition: Hash.hpp:314
static void init(const key_t &)
Definition: Hash.hpp:236
NoopHasher(Env &&env)
Definition: Hash.hpp:71
Env create_env(Meta &&meta, const std::string &options="")
Creates an environment.
bool operator==(const Iterator &o) const
Definition: Hash.hpp:501
void operator+=(char c)
Definition: Hash.hpp:343
MixHasher(Env &&env)
Definition: Hash.hpp:53
len_t mod_tablesize(const size_t index, const len_t tablesize, const size_t, const size_t)
Compute index % tablesize.
Definition: Hash.hpp:152
SizeManagerNoob(Env &&env)
Definition: Hash.hpp:139
#define tdc_unlikely(x)
Provides a hint to the compiler that x is expected to resolve to false.
Definition: def.hpp:23
ZBackupRollingHash(Env &&env)
Definition: Hash.hpp:318
size_t operator()(size_t key) const
Definition: Hash.hpp:54
std::pair< Iterator, bool > insert(std::pair< key_t, value_t > &&value)
Definition: Hash.hpp:518
LinearProber(Env &&env)
Definition: Hash.hpp:271
void reserve(len_t hint)
Definition: Hash.hpp:461
VignaHasher(Env &&env)
Definition: Hash.hpp:18
SizeManager m_sizeman
Definition: Hash.hpp:378
void resize(const len_t)
Definition: Hash.hpp:86
size_t operator()(size_t key) const
Definition: Hash.hpp:72
size_t operator()(size_t key)
Definition: Hash.hpp:41
key_type operator()()
Definition: Hash.hpp:323
static Meta meta()
Definition: Hash.hpp:159
WordpackRollingHash(Env &&env)
Definition: Hash.hpp:342
len_t mod_tablesize(const size_t, const len_t tablesize, const size_t key, const size_t probe)
Compute index % tablesize Since tablesize is a power of two, a bitwise-AND is equivalent and faster f...
Definition: Hash.hpp:125
SizeManagerPow2(Env &&env)
Definition: Hash.hpp:85
static len_t mod_tablesize(const size_t &index, const len_t &tablesize, const size_t &, const size_t &)
Compute index % tablesize Since tablesize is a power of two, a bitwise-AND is equivalent and faster...
Definition: Hash.hpp:98
static Meta meta()
Definition: Hash.hpp:338
HashFcn m_h
Definition: Hash.hpp:376
static Meta meta()
Definition: Hash.hpp:81
uint64_t operator()(uint64_t x) const
Definition: Hash.hpp:19
static len_t get_min_size(const len_t &hint)
Definition: Hash.hpp:165
void swap(IntVector< T > &lhs, IntVector< T > &rhs)
Definition: IntVector.hpp:532
void resize(const len_t)
Definition: Hash.hpp:146
Env & env()
Provides access to the environment that the algorithm works in.
Definition: Algorithm.hpp:51
void init(const key_t &key)
Definition: Hash.hpp:295
static Meta meta()
Definition: Hash.hpp:49
static len_t get_min_size(const len_t &hint)
The lowest possible size larger than hint.
Definition: Hash.hpp:91
Algorithm & operator=(Algorithm const &)=default
HashMap(Env &, const size_t n, const size_t &remaining_characters)
Definition: Hash.hpp:415
static len_t get_min_size(const len_t &hint)
The lowest possible size larger than hint.
Definition: Hash.hpp:114
static len_t mod_tablesize(const size_t &index, const len_t &tablesize, const size_t &, const size_t &)
Definition: Hash.hpp:170
static Meta meta()
Definition: Hash.hpp:369
fast_t< len_compact_t > len_t
Type to represent an length value.
Definition: def.hpp:114
len_t table_size() const
Definition: Hash.hpp:515
const size_t m_n
Definition: Hash.hpp:412
len_compact_t pos
Definition: LZSSFactors.hpp:38
len_t empty() const
Definition: Hash.hpp:516
uint64_t operator()(uint64_t x) const
Definition: Hash.hpp:27
#define IF_STATS(x)
x is compiled only when the STATS_DISABLED macro is undefined.
Definition: def.hpp:59
std::pair< key_t, value_t > store_t
Definition: Hash.hpp:367
KnuthHasher(Env &&env)
Definition: Hash.hpp:40
MoveGuard m_guard
Definition: Hash.hpp:451
SizeManagerDirect(Env &&env)
Definition: Hash.hpp:110
static void init(const key_t &)
Definition: Hash.hpp:257
static void init(const key_t &)
Definition: Hash.hpp:274
Key key_t
Definition: Hash.hpp:365
EqualKey m_eq
Definition: Hash.hpp:375
static Meta meta()
Definition: Hash.hpp:106
void operator+=(char c)
Definition: Hash.hpp:319
Value value_t
Definition: Hash.hpp:366
void incorporate(T &&o, len_t newsize)
Definition: Hash.hpp:430
static Meta meta()
Definition: Hash.hpp:135
key_type operator()()
Definition: Hash.hpp:346
Iterator & operator=(const Iterator &o)
Definition: Hash.hpp:504
static void log(const char *key, const T &value)
Logs a user statistic for the current phase.
Definition: StatPhase.hpp:218
IF_STATS(size_t m_collisions=0;size_t m_old_size=0;size_t m_resizes=0;size_t m_specialresizes=0;) public
Definition: Hash.hpp:386
SizeManagerPrime(Env &&env)
Definition: Hash.hpp:163
ProbeFcn m_probe
Definition: Hash.hpp:377
static size_t next_prime(size_t __n)
Definition: Hash.hpp:177
key_t * m_keys
Definition: Hash.hpp:380
constexpr factorid_t undef_id
Id that can be used for a non-existing factor.
Definition: LZ78Trie.hpp:14
static Meta meta()
Definition: Hash.hpp:14
static Meta meta()
Definition: Hash.hpp:36
GaussProber(Env &&env)
Definition: Hash.hpp:255
QuadraticProber(Env &&env)
Definition: Hash.hpp:234
static Meta meta()
Definition: Hash.hpp:251
float max_load_factor() const noexcept
Definition: Hash.hpp:409
Local environment for a compression/encoding/decompression call.
len_t entries() const
Definition: Hash.hpp:514
static Meta meta()
Definition: Hash.hpp:267
Interface for algorithms.
Definition: Algorithm.hpp:15
const value_t & value() const
Definition: Hash.hpp:509
static Meta meta()
Definition: Hash.hpp:67
void resize(const len_t)
Definition: Hash.hpp:117
void resize(const len_t)
Definition: Hash.hpp:168
value_t * m_values
Definition: Hash.hpp:381
#define IF_DEBUG(x)
x is compiled only in debug builds.
Definition: def.hpp:32
static len_t get_min_size(const len_t &hint)
The lowest possible size larger than hint.
Definition: Hash.hpp:143