|
Aleph-w 7.10.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. | |
| constexpr bool | get_with_resize () const noexcept |
| Returns whether the table resizes itself. | |
| void | set_with_resize (const bool with_resize) noexcept |
| Turns the automatic resizing on or off. | |
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). | |
| size_t | bucket_length (const size_t i) const |
| Returns the length of the collision chain of bucket i. | |
Static Private Member Functions | |
| static void | update_stat_len (DynArray< size_t > &lens, size_t i) |
| Updates chain length histogram. | |
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. |
|
inlineprivate |
Returns the length of the collision chain of bucket i.
| i | Bucket index, smaller than capacity(). |
Definition at line 1438 of file hashDry.H.
References HashStats< HashTbl >::const_me(), and Aleph::count().
Referenced by HashStats< HashTbl >::stats().
|
inlineprivate |
Returns a const pointer to the derived class (CRTP pattern).
Definition at line 1401 of file hashDry.H.
Referenced by HashStats< HashTbl >::bucket_length(), HashStats< HashTbl >::get_lower_alpha(), HashStats< HashTbl >::get_upper_alpha(), HashStats< HashTbl >::get_with_resize(), HashStats< HashTbl >::print_stats(), and HashStats< HashTbl >::stats().
|
inlineconstexprnoexcept |
Returns the lower load factor threshold.
Definition at line 1559 of file hashDry.H.
References HashStats< HashTbl >::const_me().
|
inlineconstexprnoexcept |
Returns the upper load factor threshold.
Definition at line 1564 of file hashDry.H.
References HashStats< HashTbl >::const_me().
|
inlineconstexprnoexcept |
|
inlineprivate |
Returns a pointer to the derived class (CRTP pattern).
Definition at line 1396 of file hashDry.H.
Referenced by HashStats< HashTbl >::set_lower_alpha(), HashStats< HashTbl >::set_upper_alpha(), and HashStats< HashTbl >::set_with_resize().
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 1511 of file hashDry.H.
References HashStats< HashTbl >::Stats::avg, HashStats< HashTbl >::const_me(), HashStats< HashTbl >::Stats::lens, Aleph::DynArray< T >::size(), sqrt(), HashStats< HashTbl >::stats(), and HashStats< HashTbl >::Stats::var.
|
inline |
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 1548 of file hashDry.H.
References ah_domain_error_if, and HashStats< HashTbl >::me().
Referenced by TEST().
|
inline |
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 1532 of file hashDry.H.
References ah_domain_error_if, and HashStats< HashTbl >::me().
Referenced by TEST().
|
inlinenoexcept |
Turns the automatic resizing on or off.
As with the thresholds, the change applies from the next insertion or removal on: turning it on does not resize the table at once. Turned off, the table keeps its capacity, and its lists get longer as keys come in.
| with_resize | true for the table to grow and shrink by itself. |
Definition at line 1580 of file hashDry.H.
References HashStats< HashTbl >::me().
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 1470 of file hashDry.H.
References HashStats< HashTbl >::Stats::avg, HashStats< HashTbl >::bucket_length(), HashStats< HashTbl >::const_me(), HashStats< HashTbl >::Stats::lens, Aleph::DynArray< T >::reserve(), 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 1426 of file hashDry.H.
References Aleph::DynArray< T >::touch().
Referenced by HashStats< HashTbl >::stats().