ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::Probing Class Reference

a sequence of inspection \( H( k , i ) \) of an OpenHashTable More...

#include <ADS/dictionary/OpenHashTable.h>

Public types

enum class  Kind {
  LINEAR , QUADRATIC , DOUBLE , TRIANGULAR ,
  RANDOM
}
 the kind of the inspection More...
using Step = std::function< std::size_t( std::size_t ) >
 the second function of the double hashing, of the hash \( h( k ) \)

Public member functions

Kind kind (void) const
 the kind of the inspection
std::size_t at (std::size_t h, std::size_t i, std::size_t m) const
 the place \( H( k , i ) \) in a table of size \( m \), from \( h = h( k ) \)
std::size_t stride (std::size_t h, std::size_t m) const
 the constant difference \( H( k , i + 1 ) - H( k , i ) \bmod m \) of the linear inspection and of the double hashing, so that a scan adds it instead of computing \( H( k , i ) \); 0 for the other inspections
bool works (std::size_t m) const
 whether the sequence can work with a table of size \( m \)
void check (std::size_t m) const
 checks that the sequence works with \( m \)

Static public member functions

static Probing linear (long delta=1)
 \( H( k , i ) = ( H_0( k ) + \delta i ) \bmod m \)
static Probing quadratic (long c1, long c2)
 \( H( k , i ) = ( H_0( k ) + c_1 i + c_2 i^2 ) \bmod m \), \( m \) prime
static Probing double_hashing (void)
 \( H( k , i ) = ( H_0( k ) + H_\delta( k ) i ) \bmod m \)
static Probing double_hashing (Step g)
 \( H( k , i ) = ( H_0( k ) + H_\delta( k ) i ) \bmod m \), the step from \( g( h( k ) ) \)
static Probing triangular (void)
 \( H( k , i ) = ( H_0( k ) + i ( i + 1 ) / 2 ) \bmod m \), \( m \) a power of two
static Probing pseudo_random (unsigned long seed=1)
 \( H( k , i ) = ( H_0( k ) + p_i ) \bmod m \), \( p \) a random permutation of \( 0 , \ldots , m - 1 \) with \( p_0 = 0 \), drawn from the seed for each \( m \)
static std::size_t step (std::size_t h, std::size_t m)
 the step \( H_\delta( k ) \) of the double hashing, coprime with \( m \) when \( m \) is prime or a power of two

Detailed description

a sequence of inspection \( H( k , i ) \) of an OpenHashTable

Member typedef documentation

◆ Step

using ADS::Probing::Step = std::function< std::size_t( std::size_t ) >

the second function of the double hashing, of the hash \( h( k ) \)

Member enumeration documentation

◆ Kind

enum class ADS::Probing::Kind
strong

the kind of the inspection

Enumerator
LINEAR 

\( ( H_0( k ) + \delta i ) \bmod m \)

QUADRATIC 

\( ( H_0( k ) + c_1 i + c_2 i^2 ) \bmod m \)

DOUBLE 

\( ( H_0( k ) + H_\delta( k ) i ) \bmod m \)

TRIANGULAR 

\( ( H_0( k ) + i ( i + 1 ) / 2 ) \bmod m \)

RANDOM 

\( ( H_0( k ) + p_i ) \bmod m \)

Member function documentation

◆ at()

std::size_t ADS::Probing::at ( std::size_t h,
std::size_t i,
std::size_t m ) const
nodiscard

the place \( H( k , i ) \) in a table of size \( m \), from \( h = h( k ) \)

Precondition
\( m > 0 \)
Postcondition
the result is below \( m \)

◆ check()

void ADS::Probing::check ( std::size_t m) const

checks that the sequence works with \( m \)

Precondition
works( m )

◆ double_hashing() [1/2]

Probing ADS::Probing::double_hashing ( Step g)
static

\( H( k , i ) = ( H_0( k ) + H_\delta( k ) i ) \bmod m \), the step from \( g( h( k ) ) \)

◆ double_hashing() [2/2]

Probing ADS::Probing::double_hashing ( void )
static

\( H( k , i ) = ( H_0( k ) + H_\delta( k ) i ) \bmod m \)

◆ kind()

Kind ADS::Probing::kind ( void ) const
nodiscard

the kind of the inspection

◆ linear()

Probing ADS::Probing::linear ( long delta = 1)
static

\( H( k , i ) = ( H_0( k ) + \delta i ) \bmod m \)

◆ pseudo_random()

Probing ADS::Probing::pseudo_random ( unsigned long seed = 1)
static

\( H( k , i ) = ( H_0( k ) + p_i ) \bmod m \), \( p \) a random permutation of \( 0 , \ldots , m - 1 \) with \( p_0 = 0 \), drawn from the seed for each \( m \)

◆ quadratic()

Probing ADS::Probing::quadratic ( long c1,
long c2 )
static

\( H( k , i ) = ( H_0( k ) + c_1 i + c_2 i^2 ) \bmod m \), \( m \) prime

◆ step()

std::size_t ADS::Probing::step ( std::size_t h,
std::size_t m )
staticnodiscard

the step \( H_\delta( k ) \) of the double hashing, coprime with \( m \) when \( m \) is prime or a power of two

Precondition
\( m > 0 \)

◆ stride()

std::size_t ADS::Probing::stride ( std::size_t h,
std::size_t m ) const
nodiscard

the constant difference \( H( k , i + 1 ) - H( k , i ) \bmod m \) of the linear inspection and of the double hashing, so that a scan adds it instead of computing \( H( k , i ) \); 0 for the other inspections

Precondition
\( m > 0 \)

◆ triangular()

Probing ADS::Probing::triangular ( void )
static

\( H( k , i ) = ( H_0( k ) + i ( i + 1 ) / 2 ) \bmod m \), \( m \) a power of two

◆ works()

bool ADS::Probing::works ( std::size_t m) const
nodiscard

whether the sequence can work with a table of size \( m \)


The documentation for this class was generated from the following file: