UniqueHasher Class Reference

#include <hash.h>

Detailed Description

UniqueHasher allows to compute a 128-bit UniqueHash from a sequence of values. The values are passed to the hasher using a series of calls to Combine() functions. At the end, the Finalize() function returns the final hash value.

Computing the hash value through a series of calls is slower than a one-shot computation of a single byte block using UniqueHash::GetUniqueHashCode(). For better performance, you should prefer the one-shot computation if possible.

Public Types

using ValueType = UniqueHash
 

Public Member Functions

 UniqueHasher ()
 
void Combine (const Block< const Byte > &bytes)
 
void Combine (const Byte *ptr, Int count)
 
void Combine (const UniqueHash &value)
 
template<typename HASH = DefaultCompare, typename... ARGS>
void HashAndCombine (const ARGS &... values)
 
UniqueHash Finalize () const
 
 operator UniqueHash () const
 

Static Public Member Functions

template<typename... H>
static UniqueHash CombineHashes (const H &... hashes)
 

Private Member Functions

template<typename HASH , typename T >
void HashAndCombineImpl (const T &value)
 

Private Attributes

UInt64 _state [72]
 

Member Typedef Documentation

◆ ValueType

Member Function Documentation

◆ HashAndCombine()

void HashAndCombine ( const ARGS &...  values)

Mixes hashes of the given values into the hasher state. If a value's type is trivially hashable, its raw bytes are used for mixing. Otherwise the hash value returned by {HASH::GetUniqueHashCode(value)} is used.

Parameters
[in]valuesValues whose hashes shall be combined into this hasher's state.

◆ CombineHashes()

static UniqueHash CombineHashes ( const H &...  hashes)
static

Computes a UniqueHash from a sequence of hash values.

Parameters
[in]hashesA sequence of hash values.
Returns
A single hash value for the sequence of hash values.

◆ HashAndCombineImpl()

void HashAndCombineImpl ( const T &  value)
private

Member Data Documentation

◆ _state

UInt64 _state[72]
private