Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
hashDry.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
33# ifndef HASHDRY_H
34# define HASHDRY_H
35
57# include <aleph.H>
58# include <tpl_dynArray.H>
59# include <ah-errors.H>
60
99template <class HashTbl, typename Key>
101{
105 HashTbl * me() { return static_cast<HashTbl*>(this); }
106
110 const HashTbl * const_me() const { return static_cast<const HashTbl*>(this); }
111
112public:
113
121 [[nodiscard]] constexpr float get_lower_alpha() const noexcept { return const_me()->lower_alpha; }
122
130 [[nodiscard]] constexpr float get_upper_alpha() const noexcept { return const_me()->upper_alpha; }
131
144 {
145 assert(me()->N == 0 and me()->len >= other.N);
146 for (long i = 0, c = 0; c < other.N; ++i)
147 {
148 auto & bucket = other.table[i];
149 if (bucket.status != HashTbl::BUSY)
150 continue;
151
152 (void)me()->insert(bucket.key);
153 ++c;
154 }
155 assert(me()->N == other.N);
156 }
157
167 {
168 for (long i = 0; i < me()->len; ++i)
169 me()->table[i].reset();
170 me()->N = 0;
171 }
172
181 {
182 // Keep at least one EMPTY bucket as a sentinel.
183 if (me()->with_resize and me()->N >= me()->len - 1)
184 me()->resize(Primes::next_prime(2 * me()->len));
185 }
186
203 [[nodiscard]] Key * insert(const Key & key)
204 {
206 auto bucket = me()->allocate_bucket(key);
207 if (bucket == nullptr)
208 return nullptr;
209
210 bucket->key = key;
211
212 return me()->test_resize(bucket, key);
213 }
214
231 [[nodiscard]] Key * insert(Key && key)
232 {
234 auto bucket = me()->allocate_bucket(key);
235 if (bucket == nullptr)
236 return nullptr;
237
238 std::swap(bucket->key, key);
239
240 return me()->test_resize(bucket, bucket->key);
241 }
242
259 [[nodiscard]] Key * search_or_insert(const Key & key)
260 {
262 auto r = me()->hard_allocate_bucket(key);
263 auto bucket = get<0>(r);
264 if (bucket == nullptr)
265 return nullptr;
266 if (get<1>(r))
267 return &bucket->key;
268
269 bucket->key = key;
270
271 return me()->test_resize(bucket, bucket->key);
272 }
273
291 [[nodiscard]] Key * search_or_insert(Key && key)
292 {
294 auto r = me()->hard_allocate_bucket(key);
295 auto bucket = get<0>(r);
296 if (bucket == nullptr)
297 return nullptr;
298 if (get<1>(r))
299 return &bucket->key;
300
301 std::swap(bucket->key, key);
302
303 return me()->test_resize(bucket, bucket->key);
304 }
305
332 [[nodiscard]] std::pair<Key*, bool> contains_or_insert(const Key & key)
333 {
335 auto r = me()->hard_allocate_bucket(key);
336 auto bucket = get<0>(r);
337 if (bucket == nullptr)
338 return { nullptr, false };
339 if (get<1>(r))
340 return { &bucket->key, true };
341
342 bucket->key = key;
343 auto key_ptr = me()->test_resize(bucket, bucket->key);
344
345 return { key_ptr, false };
346 }
347
365 [[nodiscard]] std::pair<Key*, bool> contains_or_insert(Key && key)
366 {
368 auto r = me()->hard_allocate_bucket(key);
369 auto bucket = get<0>(r);
370 if (bucket == nullptr)
371 return { nullptr, false };
372 if (get<1>(r))
373 return { &bucket->key, true };
374
375 std::swap(bucket->key, key);
376 auto key_ptr = me()->test_resize(bucket, bucket->key);
377
378 return { key_ptr, false };
379 }
380
389 [[nodiscard]] Key * append(const Key & key)
390 {
391 return this->insert(key);
392 }
393
402 [[nodiscard]] Key * append(Key && key)
403 {
404 return this->insert(std::move(key));
405 }
406
414 [[nodiscard]] constexpr bool has(const Key & key) const noexcept
415 {
416 return const_me()->search(key) != nullptr;
417 }
418
425 [[nodiscard]] constexpr bool contains(const Key & key) const noexcept { return has(key); }
426
438 [[nodiscard]] Key & find(const Key & key)
439 {
440 auto key_ptr = me()->search(key);
441 ah_domain_error_if(key_ptr == nullptr)
442 << "Key not found in hash";
443
444 return *key_ptr;
445 }
446
456 [[nodiscard]] const Key & find(const Key & key) const
457 {
458 return const_cast<OhashCommon*>(this)->find(key);
459 }
460
469 const Key & operator [] (const Key & key) const
471 return find(key);
472 }
473
482 const Key & operator [] (const Key & key)
483 {
484 return *search_or_insert(key);
485 }
486
502 void remove_ptr(Key * key)
503 {
504 auto bucket = HashTbl::key_to_bucket(key);
505 me()->deallocate_bucket(bucket);
506
507 if (me()->with_resize and me()->current_alpha() < me()->lower_alpha)
508 resize(Primes::next_prime(me()->len/2 + 1));
509 }
510
524 size_t resize(size_t new_size)
525 {
526 assert(me()->len > 0);
527
528 if (new_size == 0 or new_size == me()->len)
529 return me()->len;
530
531 // new_size must leave at least one EMPTY bucket as sentinel
533 << "New size is not enough for current number of entries";
534
535 auto * new_table = new typename HashTbl::Bucket[new_size];
536 typename HashTbl::Bucket * old_table = me()->table;
537 const size_t old_len = me()->len;
538
539 int old_N = me()->N;
540
541 me()->table = new_table;
542 me()->len = new_size;
543 me()->N = 0;
544
545 for (int i = 0, c = 0; i < old_len and c < old_N; ++i)
546 if (old_table[i].status == HashTbl::BUSY)
547 {
548 Key & key = old_table[i].key;
549 auto bucket = me()->allocate_bucket(key);
550 std::swap(bucket->key, key);
551 ++c;
552 }
553
554 assert(old_N == me()->N);
555
556 delete [] old_table;
557
558 return me()->len;
559 }
560
569 void rehash()
570 {
571 auto new_table = new typename HashTbl::Bucket [me()->len];
572 auto old_table = me()->table;
573
574 int old_N = me()->N;
575
576 me()->table = new_table;
577 me()->N = 0;
578
579 for (int i = 0, c = 0; i < me()->len and c < old_N; ++i)
580 if (old_table[i].status == HashTbl::BUSY)
581 {
582 Key & key = old_table[i].key;
583 auto bucket = me()->allocate_bucket(key);
584 std::swap(bucket->key, key);
585 ++c;
586 }
587
588 assert(old_N == me()->N);
589
590 delete [] old_table;
591 }
592
601 void empty()
602 {
603 delete [] me()->table;
604 me()->N = 0;
605 me()->len = Primes::DefaultPrime;
606 me()->table = new typename HashTbl::Bucket [me()->len];
607 }
608
614 void clear() { empty(); }
615
619 [[nodiscard]] constexpr size_t size() const noexcept { return const_me()->N; }
620
624 [[nodiscard]] constexpr bool is_empty() const noexcept { return const_me()->N == 0; }
625
629 [[nodiscard]] constexpr size_t capacity() const noexcept { return const_me()->len; }
630
654 {
655 HashTbl * table_ptr = nullptr;
656 long curr_idx = 0;
657 long ordinal = 0;
658
663 {
664 assert(table_ptr != nullptr);
667 }
668
673 {
674 assert(check());
675 if (++ordinal == table_ptr->size())
676 return;
677
678 while (table_ptr->table[++curr_idx].status != HashTbl::BUSY);
679 }
680
685 {
686 assert(check());
687 if (--ordinal == -1)
688 return;
689
690 while (table_ptr->table[--curr_idx].status != HashTbl::BUSY);
691 }
692
697 {
699 << "Iterator next() overflow";
701 }
702
707 {
709 << "Iterator next() underflow";
711 }
712
713 public:
714
721 {
722 assert(table_ptr != nullptr);
723 curr_idx = 0;
724 ordinal = -1;
725 if (table_ptr->is_empty())
726 {
727 curr_idx = table_ptr->len;
728 ordinal = 0;
729 return;
730 }
731
732 while (table_ptr->table[curr_idx].status != HashTbl::BUSY)
733 ++curr_idx;
734
735 ordinal = 0;
736 assert(check());
737 }
738
745 {
746 assert(table_ptr != nullptr);
747 if (table_ptr->is_empty())
748 {
749 curr_idx = -1;
750 ordinal = -1;
751 return;
752 }
753
754 curr_idx = table_ptr->len - 1;
755 while (table_ptr->table[curr_idx].status != HashTbl::BUSY)
756 --curr_idx;
757
758 ordinal = table_ptr->size() - 1;
759 assert(check());
760 }
761
767 {
768 put_itor_at_the_end(*this);
769 }
770
774 [[nodiscard]] constexpr long get_pos() const noexcept { return ordinal; }
775
781 {
782 assert(table_ptr->table[curr_idx].status == HashTbl::BUSY);
783 return table_ptr->table[curr_idx].key;
784 }
785
791 {
792 return const_cast<Iterator*>(this)->get_curr_ne();
793 }
794
800 Key & get_curr()
801 {
803 << "O hash::Iterator next() overflow";
804
806 << "O hash::Iterator next() underflow";
807
808 assert(check());
809
810 return get_curr_ne();
811 }
812
818 const Key & get_curr() const
819 {
820 return const_cast<Iterator*>(this)->get_curr();
821 }
822
827 {
828 assert(table_ptr != nullptr);
829 if (table_ptr->is_empty())
830 return false;
831 return ordinal >= 0 and ordinal < table_ptr->size();
832 }
833
837 [[nodiscard]] constexpr bool is_last() const noexcept { return ordinal == table_ptr->size() - 1; }
838
843
848
853
858
862
867 : table_ptr(&const_cast<HashTbl&>(table)), curr_idx(0), ordinal(-1)
868 {
869 reset_first();
870 }
871
882 void del()
883 {
885 << "Overflow in del() of iterator";
886
887 table_ptr->deallocate_bucket(&table_ptr->table[curr_idx]);
888 if (table_ptr->size() == 0)
889 return;
890
891 while (table_ptr->table[++curr_idx].status != HashTbl::BUSY);
892 }
893 };
894
905 {
906 return const_me()->template maps<Key> ([] (const Key & key) { return key; });
907 }
908
913 [[nodiscard]] auto items() const { return keys(); }
914
921 struct Stats
922 {
923 size_t num_busy = 0;
924 size_t num_deleted = 0;
925 size_t num_empty = 0;
927 float avg = 0;
928 float var = 0;
929 size_t max_len = 0;
930
933 {
934 assert(lens.size() == 0);
935 }
936 };
937
945 void print_stats(const Stats & stats) const
946 {
947 std::cout << "M = " << this->capacity() << '\n'
948 << "N = " << this->size() << '\n'
949 << "busy slots = " << stats.num_busy << '\n'
950 << "deleted slots = " << stats.num_deleted << '\n'
951 << "empty slots = " << stats.num_empty << '\n'
952 << "alpha = " << const_me()->current_alpha() << '\n'
953 << "max length = " << stats.max_len << '\n';
954 for (size_t i = 0; i < stats.lens.size(); ++i)
955 std::cout << " " << i << " = " << stats.lens(i) << '\n';
956 }
957
966 [[nodiscard]] constexpr float current_alpha() const noexcept
967 {
968 return 1.0f*const_me()->N/const_me()->len;
969 }
970};
971
972
990template <class HashTbl>
992{
996 HashTbl * me() { return static_cast<HashTbl*>(this); }
997
1001 const HashTbl * const_me() const { return static_cast<const HashTbl*>(this); }
1002
1006 size_t N = 0;
1007
1008public:
1009
1015 struct Stats
1016 {
1017 float avg;
1018 float var;
1020 };
1021
1022private:
1023
1028 static void update_stat_len(DynArray<size_t> & lens, size_t i)
1029 {
1030 if (lens.exist(i))
1031 lens(i) += 1;
1032 else
1033 lens.touch(i) = 1;
1034 }
1035
1036public:
1037
1047 Stats stats() const
1048 {
1049 DynArray<size_t> lens;
1050 for (int i = 0; i < const_me()->capacity(); ++i)
1051 {
1052 Dlink & list = const_me()->table[i];
1053 size_t count = 0;
1054 for (typename HashTbl::BucketItor it(list); it.has_curr();
1055 it.next(), ++count)
1056 ;
1057
1058 update_stat_len(lens, count);
1059 }
1060
1061 float avg = 0, sum = 0;
1062 for (size_t i = 0; i < lens.size(); ++i)
1063 {
1064 avg += lens(i)*i;
1065 sum += lens(i);
1066 }
1067 avg /= sum;
1068
1069 float var = 0;
1070 for (size_t i = 0; i < lens.size(); ++i)
1071 {
1072 float s = i - avg;
1073 var += lens(i)*s*s;
1074 }
1075 var /= sum;
1076
1077 Stats stats;
1078 stats.avg = avg;
1079 stats.var = var;
1080 std::swap(lens, stats.lens);
1081
1082 return stats;
1083 }
1084
1093 void print_stats(const Stats & stats) const
1094 {
1095 std::cout << "M = " << const_me()->capacity() << '\n'
1096 << "N = " << const_me()->size() << '\n'
1097 << "busy slots = " << busy_slots_counter << '\n'
1098 << "Average = " << stats.avg << '\n'
1099 << "Desv = " << sqrt(stats.var) << '\n'
1100 << "alpha = " << (1.0*const_me()->size())/const_me()->capacity()
1101 << '\n';
1102 for (size_t i = 0; i < stats.lens.size(); ++i)
1103 std::cout << " " << i << " = " << stats.lens(i) << '\n';
1104 }
1105
1115 {
1117 << "upper_alpha lower than lower_alpha";
1118
1120 }
1121
1131 {
1133 << "lower_alpha greater than upper_alpha";
1134
1136 }
1137
1141 [[nodiscard]] constexpr float get_lower_alpha() const noexcept { return lower_alpha; }
1142
1146 [[nodiscard]] constexpr float get_upper_alpha() const noexcept { return upper_alpha; }
1147};
1148
1149
1150# endif // HASHDRY_H
Exception handling system with formatted messages for Aleph-w.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
Definition ah-errors.H:368
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
Definition ah-errors.H:463
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Definition ah-errors.H:522
Core header for the Aleph-w library.
void put_itor_at_the_end(Itor &it) noexcept
Definition aleph.H:54
T & touch(const size_t i)
Touch the entry i.
size_t size() const noexcept
Return the current dimension of array.
bool exist(const size_t i) const
Return true if the i-th entry is accessible.
Dynamic singly linked list with functional programming support.
Definition htlist.H:1155
CRTP mixin providing statistics and configuration for chained hash tables.
Definition hashDry.H:992
constexpr float get_upper_alpha() const noexcept
Returns the upper load factor threshold.
Definition hashDry.H:1146
void set_upper_alpha(float _upper_alpha)
Sets the upper load factor threshold.
Definition hashDry.H:1114
float lower_alpha
Lower load factor threshold for shrinking.
Definition hashDry.H:1003
HashTbl * me()
Returns a pointer to the derived class (CRTP pattern).
Definition hashDry.H:996
float upper_alpha
Upper load factor threshold for growing.
Definition hashDry.H:1004
void set_lower_alpha(float _lower_alpha)
Sets the lower load factor threshold.
Definition hashDry.H:1130
Stats stats() const
Computes statistics about chain length distribution.
Definition hashDry.H:1047
static void update_stat_len(DynArray< size_t > &lens, size_t i)
Updates chain length histogram.
Definition hashDry.H:1028
size_t busy_slots_counter
Number of buckets with at least one entry.
Definition hashDry.H:1005
size_t N
Total number of entries.
Definition hashDry.H:1006
void print_stats(const Stats &stats) const
Prints statistics to standard output.
Definition hashDry.H:1093
const HashTbl * const_me() const
Returns a const pointer to the derived class (CRTP pattern).
Definition hashDry.H:1001
constexpr float get_lower_alpha() const noexcept
Returns the lower load factor threshold.
Definition hashDry.H:1141
Bidirectional iterator for traversing hash table entries.
Definition hashDry.H:654
Key & get_curr()
Returns a reference to the current entry with bounds checking.
Definition hashDry.H:800
Iterator() noexcept=default
Default constructor creates an "end" iterator.
bool check() const noexcept
Validates iterator state (debug only).
Definition hashDry.H:662
bool has_curr() const noexcept
Checks if the iterator is at a valid position.
Definition hashDry.H:826
constexpr long get_pos() const noexcept
Returns the current logical position.
Definition hashDry.H:774
const Key & get_curr() const
Returns a const reference to the current entry with bounds checking.
Definition hashDry.H:818
void del()
Deletes the current entry and advances to the next.
Definition hashDry.H:882
void end() noexcept
Positions the iterator at the end (past-the-last element).
Definition hashDry.H:766
HashTbl * table_ptr
Pointer to the hash table being iterated.
Definition hashDry.H:655
void prev()
Moves to the previous entry with bounds checking.
Definition hashDry.H:857
void next()
Advances to the next entry with bounds checking.
Definition hashDry.H:842
long curr_idx
Current bucket index.
Definition hashDry.H:656
const Key & get_curr_ne() const noexcept
Returns a const reference to the current entry without checking.
Definition hashDry.H:790
void locate_next_available_entry()
Advances to next entry with bounds checking.
Definition hashDry.H:696
void prev_ne()
Moves to the previous entry without bounds checking.
Definition hashDry.H:852
void locate_prev_available_entry_ne()
Moves to previous entry without bounds checking.
Definition hashDry.H:684
Key & get_curr_ne() noexcept
Returns a reference to the current entry without checking.
Definition hashDry.H:780
void reset_first() noexcept
Positions the iterator at the first entry.
Definition hashDry.H:720
void reset_last() noexcept
Positions the iterator at the last entry.
Definition hashDry.H:744
void locate_prev_available_entry()
Moves to previous entry with bounds checking.
Definition hashDry.H:706
long ordinal
Logical position (0-based count of visited entries).
Definition hashDry.H:657
void next_ne() noexcept
Advances to the next entry without bounds checking.
Definition hashDry.H:847
void locate_next_available_entry_ne() noexcept
Advances to next entry without bounds checking.
Definition hashDry.H:672
constexpr bool is_last() const noexcept
Checks if the iterator is at the last entry.
Definition hashDry.H:837
CRTP mixin providing common operations for open addressing hash tables.
Definition hashDry.H:101
HashTbl * me()
Returns a pointer to the derived class (CRTP pattern).
Definition hashDry.H:105
Key * append(const Key &key)
Alias for insert() (copy version).
Definition hashDry.H:389
std::pair< Key *, bool > contains_or_insert(const Key &key)
Searches for a key, inserting if not found, with existence flag (copy version).
Definition hashDry.H:332
constexpr size_t size() const noexcept
Returns the number of entries in the table.
Definition hashDry.H:619
std::pair< Key *, bool > contains_or_insert(Key &&key)
Searches for a key, inserting if not found, with existence flag (move version).
Definition hashDry.H:365
Key * search_or_insert(const Key &key)
Searches for a key, inserting it if not found (copy version).
Definition hashDry.H:259
constexpr size_t capacity() const noexcept
Returns the current capacity of the table.
Definition hashDry.H:629
Key * search_or_insert(Key &&key)
Searches for a key, inserting it if not found (move version).
Definition hashDry.H:291
void clear()
Empties the container.
Definition hashDry.H:614
size_t resize(size_t new_size)
Resizes the hash table to a new capacity.
Definition hashDry.H:524
void clean_table()
Removes all entries from the table without deallocating storage.
Definition hashDry.H:166
constexpr float get_upper_alpha() const noexcept
Returns the upper load factor threshold for automatic growing.
Definition hashDry.H:130
const Key & find(const Key &key) const
Finds a key and returns a const reference to it.
Definition hashDry.H:456
void empty()
Clears all entries and resets to default capacity.
Definition hashDry.H:601
constexpr bool is_empty() const noexcept
Checks if the table is empty.
Definition hashDry.H:624
void copy_from_table(const HashTbl &other)
Copies all entries from another hash table.
Definition hashDry.H:143
void print_stats(const Stats &stats) const
Prints statistics to standard output.
Definition hashDry.H:945
void remove_ptr(Key *key)
Removes an entry by pointer.
Definition hashDry.H:502
DynList< Key > keys() const
Returns a list containing all keys in the table.
Definition hashDry.H:904
Key * insert(Key &&key)
Inserts a key into the hash table (move version).
Definition hashDry.H:231
const Key & operator[](const Key &key) const
Subscript operator for const access.
Definition hashDry.H:469
constexpr float get_lower_alpha() const noexcept
Returns the lower load factor threshold for automatic shrinking.
Definition hashDry.H:121
Key * insert(const Key &key)
Inserts a key into the hash table (copy version).
Definition hashDry.H:203
constexpr bool has(const Key &key) const noexcept
Checks if a key exists in the table.
Definition hashDry.H:414
constexpr bool contains(const Key &key) const noexcept
Alias for has().
Definition hashDry.H:425
Key & find(const Key &key)
Finds a key and returns a reference to it.
Definition hashDry.H:438
void rehash()
Rebuilds the hash table with the same capacity.
Definition hashDry.H:569
void check_resize_before_insert()
Checks if resize is needed before inserting and performs it.
Definition hashDry.H:180
Key * append(Key &&key)
Alias for insert() (move version).
Definition hashDry.H:402
auto items() const
Alias for keys().
Definition hashDry.H:913
constexpr float current_alpha() const noexcept
Returns the current load factor (alpha).
Definition hashDry.H:966
const HashTbl * const_me() const
Returns a const pointer to the derived class (CRTP pattern).
Definition hashDry.H:110
#define N
Definition fib.C:294
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sqrt_function > > sqrt(const __gmp_expr< T, U > &expr)
Definition gmpfrxx.h:4058
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_min_function > > min(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Definition gmpfrxx.h:4111
and
Check uniqueness with explicit hash + equality functors.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Definition ahAlgo.H:127
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
const unsigned long DefaultPrime
Default prime number used when no specific size is requested.
Definition primes.C:381
size_t next_prime(unsigned long n)
Find the smallest prime number >= n from the database.
Definition primes.C:383
STL namespace.
Statistics about chain length distribution.
Definition hashDry.H:1016
DynArray< size_t > lens
Distribution: lens[i] = number of chains with length i.
Definition hashDry.H:1019
float avg
Average chain length.
Definition hashDry.H:1017
float var
Variance of chain lengths.
Definition hashDry.H:1018
Statistics about hash table performance.
Definition hashDry.H:922
size_t num_deleted
Number of buckets marked as deleted.
Definition hashDry.H:924
size_t num_empty
Number of empty buckets.
Definition hashDry.H:925
DynArray< size_t > lens
Distribution of probe sequence lengths.
Definition hashDry.H:926
float avg
Average probe sequence length.
Definition hashDry.H:927
Stats()
Default constructor initializing max_len to minimum.
Definition hashDry.H:932
size_t num_busy
Number of occupied buckets.
Definition hashDry.H:923
float var
Variance of probe sequence lengths.
Definition hashDry.H:928
size_t max_len
Maximum probe sequence length.
Definition hashDry.H:929
int keys[]
gsl_rng * r
Lazy and scalable dynamic array implementation.