libboxes
boxes is a set of specialised containers built on top of STL
Classes | Concepts | Functions
hash_utils.hpp File Reference

Contains utilities for instantiating hash functions and hash families. More...

#include "compiler.hpp"
#include <concepts>
#include <cstdint>
#include <random>
#include <set>
#include <string>
#include <vector>
Include dependency graph for hash_utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  boxes::hash::KirschMitzenmacher< H1, H2 >
 Abstracts a Kirsch-Mitzenmacher hash family functor. More...
 
class  boxes::hash::HashWithSeedFamily< HashT >
 Abstracts a hash family functor that requires a seed n times with different seed. More...
 

Concepts

concept  boxes::hash::Hash64
 Defines a minimal interface for Hashing functor.
 
concept  boxes::hash::HashFamily64
 Defines a minimal interface for HashFamily functor.
 

Functions

template<typename HashFamilyT , typename T >
uint64_t boxes::hash::hashType64 (HashFamilyT &h, std::size_t idx, const T &t)
 Applies a given hash family to a type T More...
 
template<typename HashFamilyT >
uint64_t boxes::hash::hashType64 (HashFamilyT &h, std::size_t idx, const std::string &s)
 Applies a given hash family to a string. More...
 
template<typename HashFamilyT , typename T >
uint64_t boxes::hash::hashType64 (HashFamilyT &h, std::size_t idx, const std::vector< T > &v)
 Applies a given hash family to a vector of type T More...
 
template<typename HashFamilyT >
uint64_t boxes::hash::hashType64 (HashFamilyT &h, std::size_t idx, const std::vector< std::string > &v)
 Applies a given hash family to a vector of strings. More...
 
template<Hash64 HT>
HT boxes::hash::makeHashWithRandomSeed ()
 Instantiates a hash function that requires a seed with a randomly generated seed. More...
 
template<Hash64 H1, Hash64 H2>
KirschMitzenmacher< H1, H2 > boxes::hash::makeKirschMitzenmacher (H1 h1, H2 h2, std::size_t k)
 Helper function to instantiate a Kirsch-Mitzenmacher hash family. More...
 

Detailed Description

Contains utilities for instantiating hash functions and hash families.

Copyright 2024 Tomasz Wisniewski twdev.nosp@m..blo.nosp@m.gger@.nosp@m.gmai.nosp@m.l.com

Definition in file hash_utils.hpp.

Function Documentation

◆ hashType64() [1/4]

template<typename HashFamilyT >
uint64_t boxes::hash::hashType64 ( HashFamilyT &  h,
std::size_t  idx,
const std::string &  s 
)

Applies a given hash family to a string.

This is an overload for an adapter that applies a hash family to a string.

Template Parameters
HashFamilyTtype of the hash family functor
Parameters
hhash family functor instance
idxindex of the hash function in the family
sstring to be hashed
Returns
uint64_t hash value

Definition at line 96 of file hash_utils.hpp.

◆ hashType64() [2/4]

template<typename HashFamilyT >
uint64_t boxes::hash::hashType64 ( HashFamilyT &  h,
std::size_t  idx,
const std::vector< std::string > &  v 
)

Applies a given hash family to a vector of strings.

Template Parameters
HashFamilyTtype of the hash family functor
Parameters
hhash family functor instance
idxindex of the hash function in the family
vvector of strings to be hashed
Returns
hash value

Definition at line 127 of file hash_utils.hpp.

◆ hashType64() [3/4]

template<typename HashFamilyT , typename T >
uint64_t boxes::hash::hashType64 ( HashFamilyT &  h,
std::size_t  idx,
const std::vector< T > &  v 
)

Applies a given hash family to a vector of type T

Template Parameters
HashFamilyTtype of the hash family functor
Ttype of the data stored in the vector
Parameters
hhash family functor instance
idxindex of the hash function in the family
vvector of data to be hashed
Returns
hash value

Definition at line 112 of file hash_utils.hpp.

◆ hashType64() [4/4]

template<typename HashFamilyT , typename T >
uint64_t boxes::hash::hashType64 ( HashFamilyT &  h,
std::size_t  idx,
const T &  t 
)

Applies a given hash family to a type T

This is a generic overload for an adapter that applies a hash family to an instance of type T.

Template Parameters
HashFamilyTtype of the hash family functor
Ttype of the data to be hashed
Parameters
hhash family functor instance
idxindex of the hash function in the family
tdata to be hashed
Returns
uint64_t hash value

Definition at line 79 of file hash_utils.hpp.

◆ makeHashWithRandomSeed()

template<Hash64 HT>
HT boxes::hash::makeHashWithRandomSeed ( )

Instantiates a hash function that requires a seed with a randomly generated seed.

Template Parameters
HTtype of the hash functor
Returns
HT hash functor instance

Definition at line 142 of file hash_utils.hpp.

◆ makeKirschMitzenmacher()

template<Hash64 H1, Hash64 H2>
KirschMitzenmacher< H1, H2 > boxes::hash::makeKirschMitzenmacher ( H1  h1,
H2  h2,
std::size_t  k 
)

Helper function to instantiate a Kirsch-Mitzenmacher hash family.

Parameters
h1
h2
k
Returns

Definition at line 254 of file hash_utils.hpp.