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
470 {
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
612 [[nodiscard]] constexpr size_t size() const noexcept { return const_me()->N; }
613
617 [[nodiscard]] constexpr bool is_empty() const noexcept { return const_me()->N == 0; }
618
622 [[nodiscard]] constexpr size_t capacity() const noexcept { return const_me()->len; }
623
647 {
648 HashTbl * table_ptr = nullptr;
649 long curr_idx = 0;
650 long ordinal = 0;
651
656 {
657 assert(table_ptr != nullptr);
660 }
661
666 {
667 assert(check());
668 if (++ordinal == table_ptr->size())
669 return;
670
671 while (table_ptr->table[++curr_idx].status != HashTbl::BUSY);
672 }
673
678 {
679 assert(check());
680 if (--ordinal == -1)
681 return;
682
683 while (table_ptr->table[--curr_idx].status != HashTbl::BUSY);
684 }
685
690 {
692 << "Iterator next() overflow";
694 }
695
700 {
702 << "Iterator next() underflow";
704 }
705
706 public:
707
714 {
715 assert(table_ptr != nullptr);
716 curr_idx = 0;
717 ordinal = -1;
718 if (table_ptr->is_empty())
719 {
720 curr_idx = table_ptr->len;
721 ordinal = 0;
722 return;
723 }
724
725 while (table_ptr->table[curr_idx].status != HashTbl::BUSY)
726 ++curr_idx;
727
728 ordinal = 0;
729 assert(check());
730 }
731
738 {
739 assert(table_ptr != nullptr);
740 if (table_ptr->is_empty())
741 {
742 curr_idx = -1;
743 ordinal = -1;
744 return;
745 }
746
747 curr_idx = table_ptr->len - 1;
748 while (table_ptr->table[curr_idx].status != HashTbl::BUSY)
749 --curr_idx;
750
751 ordinal = table_ptr->size() - 1;
752 assert(check());
753 }
754
760 {
761 put_itor_at_the_end(*this);
762 }
763
767 [[nodiscard]] constexpr long get_pos() const noexcept { return ordinal; }
768
774 {
775 assert(table_ptr->table[curr_idx].status == HashTbl::BUSY);
776 return table_ptr->table[curr_idx].key;
777 }
778
784 {
785 return const_cast<Iterator*>(this)->get_curr_ne();
786 }
787
793 Key & get_curr()
794 {
796 << "O hash::Iterator next() overflow";
797
799 << "O hash::Iterator next() underflow";
800
801 assert(check());
802
803 return get_curr_ne();
804 }
805
811 const Key & get_curr() const
812 {
813 return const_cast<Iterator*>(this)->get_curr();
814 }
815
820 {
821 assert(table_ptr != nullptr);
822 if (table_ptr->is_empty())
823 return false;
824 return ordinal >= 0 and ordinal < table_ptr->size();
825 }
826
830 [[nodiscard]] constexpr bool is_last() const noexcept { return ordinal == table_ptr->size() - 1; }
831
836
841
846
851
855
860 : table_ptr(&const_cast<HashTbl&>(table)), curr_idx(0), ordinal(-1)
861 {
862 reset_first();
863 }
864
875 void del()
876 {
878 << "Overflow in del() of iterator";
879
880 table_ptr->deallocate_bucket(&table_ptr->table[curr_idx]);
881 if (table_ptr->size() == 0)
882 return;
883
884 while (table_ptr->table[++curr_idx].status != HashTbl::BUSY);
885 }
886 };
887
898 {
899 return const_me()->template maps<Key> ([] (const Key & key) { return key; });
900 }
901
906 [[nodiscard]] auto items() const { return keys(); }
907
914 struct Stats
915 {
916 size_t num_busy = 0;
917 size_t num_deleted = 0;
918 size_t num_empty = 0;
920 float avg = 0;
921 float var = 0;
922 size_t max_len = 0;
923
926 {
927 assert(lens.size() == 0);
928 }
929 };
930
938 void print_stats(const Stats & stats) const
939 {
940 std::cout << "M = " << this->capacity() << '\n'
941 << "N = " << this->size() << '\n'
942 << "busy slots = " << stats.num_busy << '\n'
943 << "deleted slots = " << stats.num_deleted << '\n'
944 << "empty slots = " << stats.num_empty << '\n'
945 << "alpha = " << const_me()->current_alpha() << '\n'
946 << "max length = " << stats.max_len << '\n';
947 for (size_t i = 0; i < stats.lens.size(); ++i)
948 std::cout << " " << i << " = " << stats.lens(i) << '\n';
949 }
950
959 [[nodiscard]] constexpr float current_alpha() const noexcept
960 {
961 return 1.0f*const_me()->N/const_me()->len;
962 }
963};
964
965
983template <class HashTbl>
985{
989 HashTbl * me() { return static_cast<HashTbl*>(this); }
990
994 const HashTbl * const_me() const { return static_cast<const HashTbl*>(this); }
995
999 size_t N = 0;
1000
1001public:
1002
1008 struct Stats
1009 {
1010 float avg;
1011 float var;
1013 };
1014
1015private:
1016
1021 static void update_stat_len(DynArray<size_t> & lens, size_t i)
1022 {
1023 if (lens.exist(i))
1024 lens(i) += 1;
1025 else
1026 lens.touch(i) = 1;
1027 }
1028
1029public:
1030
1040 Stats stats() const
1041 {
1042 DynArray<size_t> lens;
1043 for (int i = 0; i < const_me()->capacity(); ++i)
1044 {
1045 Dlink & list = const_me()->table[i];
1046 size_t count = 0;
1047 for (typename HashTbl::BucketItor it(list); it.has_curr();
1048 it.next(), ++count)
1049 ;
1050
1051 update_stat_len(lens, count);
1052 }
1053
1054 float avg = 0, sum = 0;
1055 for (size_t i = 0; i < lens.size(); ++i)
1056 {
1057 avg += lens(i)*i;
1058 sum += lens(i);
1059 }
1060 avg /= sum;
1061
1062 float var = 0;
1063 for (size_t i = 0; i < lens.size(); ++i)
1064 {
1065 float s = i - avg;
1066 var += lens(i)*s*s;
1067 }
1068 var /= sum;
1069
1070 Stats stats;
1071 stats.avg = avg;
1072 stats.var = var;
1073 std::swap(lens, stats.lens);
1074
1075 return stats;
1076 }
1077
1086 void print_stats(const Stats & stats) const
1087 {
1088 std::cout << "M = " << const_me()->capacity() << '\n'
1089 << "N = " << const_me()->size() << '\n'
1090 << "busy slots = " << busy_slots_counter << '\n'
1091 << "Average = " << stats.avg << '\n'
1092 << "Desv = " << sqrt(stats.var) << '\n'
1093 << "alpha = " << (1.0*const_me()->size())/const_me()->capacity()
1094 << '\n';
1095 for (size_t i = 0; i < stats.lens.size(); ++i)
1096 std::cout << " " << i << " = " << stats.lens(i) << '\n';
1097 }
1098
1108 {
1110 << "upper_alpha lower than lower_alpha";
1111
1113 }
1114
1124 {
1126 << "lower_alpha greater than upper_alpha";
1127
1129 }
1130
1134 [[nodiscard]] constexpr float get_lower_alpha() const noexcept { return lower_alpha; }
1135
1139 [[nodiscard]] constexpr float get_upper_alpha() const noexcept { return upper_alpha; }
1140};
1141
1142
1143# 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:1423
T & insert(const T &item)
Insert a new item by copy.
Definition htlist.H:1502
size_t size() const noexcept
Count the number of elements of the list.
Definition htlist.H:1319
CRTP mixin providing statistics and configuration for chained hash tables.
Definition hashDry.H:985
constexpr float get_upper_alpha() const noexcept
Returns the upper load factor threshold.
Definition hashDry.H:1139
float lower_alpha
Lower load factor threshold for shrinking.
Definition hashDry.H:996
HashTbl * me()
Returns a pointer to the derived class (CRTP pattern).
Definition hashDry.H:989
float upper_alpha
Upper load factor threshold for growing.
Definition hashDry.H:997
Stats stats() const
Computes statistics about chain length distribution.
Definition hashDry.H:1040
static void update_stat_len(DynArray< size_t > &lens, size_t i)
Updates chain length histogram.
Definition hashDry.H:1021
size_t busy_slots_counter
Number of buckets with at least one entry.
Definition hashDry.H:998
void set_upper_alpha(float __upper_alpha)
Sets the upper load factor threshold.
Definition hashDry.H:1107
size_t N
Total number of entries.
Definition hashDry.H:999
void print_stats(const Stats &stats) const
Prints statistics to standard output.
Definition hashDry.H:1086
void set_lower_alpha(float __lower_alpha)
Sets the lower load factor threshold.
Definition hashDry.H:1123
const HashTbl * const_me() const
Returns a const pointer to the derived class (CRTP pattern).
Definition hashDry.H:994
constexpr float get_lower_alpha() const noexcept
Returns the lower load factor threshold.
Definition hashDry.H:1134
Bidirectional iterator for traversing hash table entries.
Definition hashDry.H:647
Key & get_curr()
Returns a reference to the current entry with bounds checking.
Definition hashDry.H:793
Iterator() noexcept=default
Default constructor creates an "end" iterator.
bool check() const noexcept
Validates iterator state (debug only).
Definition hashDry.H:655
bool has_curr() const noexcept
Checks if the iterator is at a valid position.
Definition hashDry.H:819
constexpr long get_pos() const noexcept
Returns the current logical position.
Definition hashDry.H:767
const Key & get_curr() const
Returns a const reference to the current entry with bounds checking.
Definition hashDry.H:811
void del()
Deletes the current entry and advances to the next.
Definition hashDry.H:875
void end() noexcept
Positions the iterator at the end (past-the-last element).
Definition hashDry.H:759
HashTbl * table_ptr
Pointer to the hash table being iterated.
Definition hashDry.H:648
void prev()
Moves to the previous entry with bounds checking.
Definition hashDry.H:850
void next()
Advances to the next entry with bounds checking.
Definition hashDry.H:835
long curr_idx
Current bucket index.
Definition hashDry.H:649
const Key & get_curr_ne() const noexcept
Returns a const reference to the current entry without checking.
Definition hashDry.H:783
void locate_next_available_entry()
Advances to next entry with bounds checking.
Definition hashDry.H:689
void prev_ne()
Moves to the previous entry without bounds checking.
Definition hashDry.H:845
void locate_prev_available_entry_ne()
Moves to previous entry without bounds checking.
Definition hashDry.H:677
Key & get_curr_ne() noexcept
Returns a reference to the current entry without checking.
Definition hashDry.H:773
void reset_first() noexcept
Positions the iterator at the first entry.
Definition hashDry.H:713
void reset_last() noexcept
Positions the iterator at the last entry.
Definition hashDry.H:737
void locate_prev_available_entry()
Moves to previous entry with bounds checking.
Definition hashDry.H:699
long ordinal
Logical position (0-based count of visited entries).
Definition hashDry.H:650
void next_ne() noexcept
Advances to the next entry without bounds checking.
Definition hashDry.H:840
void locate_next_available_entry_ne() noexcept
Advances to next entry without bounds checking.
Definition hashDry.H:665
constexpr bool is_last() const noexcept
Checks if the iterator is at the last entry.
Definition hashDry.H:830
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:612
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:622
Key * search_or_insert(Key &&key)
Searches for a key, inserting it if not found (move version).
Definition hashDry.H:291
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:617
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:938
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:897
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:906
constexpr float current_alpha() const noexcept
Returns the current load factor (alpha).
Definition hashDry.H:959
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
DynList< T > maps(const C &c, Op op)
Classic map operation.
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:1009
DynArray< size_t > lens
Distribution: lens[i] = number of chains with length i.
Definition hashDry.H:1012
float avg
Average chain length.
Definition hashDry.H:1010
float var
Variance of chain lengths.
Definition hashDry.H:1011
Statistics about hash table performance.
Definition hashDry.H:915
size_t num_deleted
Number of buckets marked as deleted.
Definition hashDry.H:917
size_t num_empty
Number of empty buckets.
Definition hashDry.H:918
DynArray< size_t > lens
Distribution of probe sequence lengths.
Definition hashDry.H:919
float avg
Average probe sequence length.
Definition hashDry.H:920
Stats()
Default constructor initializing max_len to minimum.
Definition hashDry.H:925
size_t num_busy
Number of occupied buckets.
Definition hashDry.H:916
float var
Variance of probe sequence lengths.
Definition hashDry.H:921
size_t max_len
Maximum probe sequence length.
Definition hashDry.H:922
Lazy and scalable dynamic array implementation.