|
ADS
Algorithms and Data Structures
|
\( h( k ) = \sum_i a_i k_i \bmod m \), the \( k_i \) being the digits of \( k \) in base \( m \) More...
#include <ADS/dictionary/UniversalHashing.h>
Public member functions | |
| DotProductHash (std::uint64_t m, int r, std::uint64_t seed=1) | |
| a function with \( r \) random digits \( a_i \), from the seed | |
| DotProductHash (std::uint64_t m, std::vector< std::uint64_t > a) | |
| the function of the digits \( a \) | |
| std::uint64_t | operator() (std::uint64_t k) const |
| \( h( k ) \) | |
| std::uint64_t | universe (void) const |
| the size \( m^r \) of the universe, or 0 if it exceeds \( 2^{64} - 1 \) | |
\( h( k ) = \sum_i a_i k_i \bmod m \), the \( k_i \) being the digits of \( k \) in base \( m \)
| ADS::DotProductHash::DotProductHash | ( | std::uint64_t | m, |
| int | r, | ||
| std::uint64_t | seed = 1 ) |
a function with \( r \) random digits \( a_i \), from the seed
| ADS::DotProductHash::DotProductHash | ( | std::uint64_t | m, |
| std::vector< std::uint64_t > | a ) |
the function of the digits \( a \)
|
nodiscard |
\( h( k ) \)
In pseudocode (chapter 8 of Ferragina):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ h( k ) \cr 2 & \quad s \gets 0 \cr 3 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ r - 1\ \textbf{do} \cr 4 & \qquad s \gets ( s + a_i ( k \bmod m ) ) \bmod m;\ k \gets \lfloor k / m \rfloor \cr 5 & \quad \textbf{return}\ s \end{array}} \]
|
nodiscard |
the size \( m^r \) of the universe, or 0 if it exceeds \( 2^{64} - 1 \)