|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
CRTP mixin providing statistics and configuration for chained hash tables. More...
#include <hashDry.H>
Classes | |
| struct | Stats |
| Statistics about chain length distribution. More... | |
Public Member Functions | |
| Stats | stats () const |
| Computes statistics about chain length distribution. | |
| void | print_stats (const Stats &stats) const |
| Prints statistics to standard output. | |
| void | set_upper_alpha (float __upper_alpha) |
| Sets the upper load factor threshold. | |
| void | set_lower_alpha (float __lower_alpha) |
| Sets the lower load factor threshold. | |
| constexpr float | get_lower_alpha () const noexcept |
| Returns the lower load factor threshold. | |
| constexpr float | get_upper_alpha () const noexcept |
| Returns the upper load factor threshold. | |
Private Member Functions | |
| HashTbl * | me () |
| Returns a pointer to the derived class (CRTP pattern). | |
| const HashTbl * | const_me () const |
| Returns a const pointer to the derived class (CRTP pattern). | |
Static Private Member Functions | |
| static void | update_stat_len (DynArray< size_t > &lens, size_t i) |
| Updates chain length histogram. | |
Private Attributes | |
| float | lower_alpha |
| Lower load factor threshold for shrinking. | |
| float | upper_alpha |
| Upper load factor threshold for growing. | |
| size_t | busy_slots_counter = 0 |
| Number of buckets with at least one entry. | |
| size_t | N = 0 |
| Total number of entries. | |
CRTP mixin providing statistics and configuration for chained hash tables.
This class provides statistics gathering and load factor configuration for hash tables using separate chaining (linked lists per bucket). It uses CRTP for static polymorphism.
| HashTbl | The derived hash table class. |
Returns a const pointer to the derived class (CRTP pattern).
Definition at line 994 of file hashDry.H.
References Aleph::maps().
Referenced by HashStats< HashTbl >::print_stats(), and HashStats< HashTbl >::stats().
Returns the lower load factor threshold.
Definition at line 1134 of file hashDry.H.
References HashStats< HashTbl >::lower_alpha.
Returns the upper load factor threshold.
Definition at line 1139 of file hashDry.H.
References HashStats< HashTbl >::upper_alpha.
Returns a pointer to the derived class (CRTP pattern).
Definition at line 989 of file hashDry.H.
References Aleph::maps().
Prints statistics to standard output.
Displays formatted statistics including capacity, size, busy slots, average chain length, standard deviation, load factor, and chain length distribution.
| stats | Statistics object to print. |
Definition at line 1086 of file hashDry.H.
References HashStats< HashTbl >::Stats::avg, HashStats< HashTbl >::busy_slots_counter, HashStats< HashTbl >::const_me(), HashStats< HashTbl >::Stats::lens, Aleph::DynArray< T >::size(), sqrt(), HashStats< HashTbl >::stats(), and HashStats< HashTbl >::Stats::var.
Sets the lower load factor threshold.
When the load factor drops below this value after a removal, the table automatically shrinks (if auto-resize is enabled).
| __lower_alpha | New lower threshold. |
| std::domain_error | If __lower_alpha >= upper_alpha. |
Definition at line 1123 of file hashDry.H.
References ah_domain_error_if, HashStats< HashTbl >::lower_alpha, Aleph::maps(), and HashStats< HashTbl >::upper_alpha.
Sets the upper load factor threshold.
When the load factor exceeds this value, the table automatically grows (if auto-resize is enabled).
| __upper_alpha | New upper threshold. |
| std::domain_error | If __upper_alpha <= lower_alpha. |
Definition at line 1107 of file hashDry.H.
References ah_domain_error_if, HashStats< HashTbl >::lower_alpha, Aleph::maps(), and HashStats< HashTbl >::upper_alpha.
Computes statistics about chain length distribution.
Iterates through all buckets to compute the distribution of chain lengths, along with mean and variance.
Definition at line 1040 of file hashDry.H.
References HashStats< HashTbl >::Stats::avg, HashStats< HashTbl >::const_me(), Aleph::count(), HashStats< HashTbl >::Stats::lens, Aleph::DynArray< T >::size(), HashStats< HashTbl >::stats(), Aleph::sum(), HashStats< HashTbl >::update_stat_len(), and HashStats< HashTbl >::Stats::var.
Referenced by HashStats< HashTbl >::print_stats(), and HashStats< HashTbl >::stats().
|
inlinestaticprivate |
Updates chain length histogram.
| lens | The histogram array to update. |
| i | The chain length to record. |
Definition at line 1021 of file hashDry.H.
References Aleph::DynArray< T >::exist(), and Aleph::DynArray< T >::touch().
Referenced by HashStats< HashTbl >::stats().
Number of buckets with at least one entry.
Definition at line 998 of file hashDry.H.
Referenced by HashStats< HashTbl >::print_stats().
Lower load factor threshold for shrinking.
Definition at line 996 of file hashDry.H.
Referenced by HashStats< HashTbl >::get_lower_alpha(), HashStats< HashTbl >::set_lower_alpha(), and HashStats< HashTbl >::set_upper_alpha().
Upper load factor threshold for growing.
Definition at line 997 of file hashDry.H.
Referenced by HashStats< HashTbl >::get_upper_alpha(), HashStats< HashTbl >::set_lower_alpha(), and HashStats< HashTbl >::set_upper_alpha().