|
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 1001 of file hashDry.H.
References Aleph::divide_and_conquer_partition_dp().
Referenced by HashStats< HashTbl >::print_stats(), and HashStats< HashTbl >::stats().
Returns the lower load factor threshold.
Definition at line 1141 of file hashDry.H.
References HashStats< HashTbl >::lower_alpha.
Returns the upper load factor threshold.
Definition at line 1146 of file hashDry.H.
References HashStats< HashTbl >::upper_alpha.
Returns a pointer to the derived class (CRTP pattern).
Definition at line 996 of file hashDry.H.
References Aleph::divide_and_conquer_partition_dp().
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 1093 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 1130 of file hashDry.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), HashStats< HashTbl >::lower_alpha, 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 1114 of file hashDry.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), HashStats< HashTbl >::lower_alpha, 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 1047 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(), HashStats< HashTbl >::stats(), Aleph::adversarial_search_detail::store_adversarial_transposition(), and TEST().
|
inlinestaticprivate |
Updates chain length histogram.
| lens | The histogram array to update. |
| i | The chain length to record. |
Definition at line 1028 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 1005 of file hashDry.H.
Referenced by HashStats< HashTbl >::print_stats().
Lower load factor threshold for shrinking.
Definition at line 1003 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 1004 of file hashDry.H.
Referenced by HashStats< HashTbl >::get_upper_alpha(), HashStats< HashTbl >::set_lower_alpha(), and HashStats< HashTbl >::set_upper_alpha().