XII Release 0.1.0
Loading...
Searching...
No Matches
xiiHashingUtils Class Reference

This class provides implementations of different hashing algorithms. More...

#include <HashingUtils.h>

Public Member Functions

template<size_t N>
constexpr XII_ALWAYS_INLINE xiiUInt32 MurmurHash32String (const char(&str)[N], xiiUInt32 uiSeed)
 
template<size_t N>
constexpr XII_ALWAYS_INLINE xiiUInt64 StringHash (const char(&str)[N], xiiUInt64 uiSeed)
 
template<size_t N>
constexpr XII_ALWAYS_INLINE xiiUInt32 xxHash32String (const char(&str)[N], xiiUInt32 uiSeed)
 
template<size_t N>
constexpr XII_ALWAYS_INLINE xiiUInt64 xxHash64String (const char(&str)[N], xiiUInt64 uiSeed)
 

Static Public Member Functions

static xiiUInt32 CRC32Hash (const void *pKey, size_t uiSizeInBytes)
 Calculates the CRC32 checksum of the given key.
 
static xiiUInt32 MurmurHash32 (const void *pKey, size_t uiSizeInByte, xiiUInt32 uiSeed=0)
 Calculates the 32bit murmur hash of the given key.
 
static xiiUInt64 MurmurHash64 (const void *pKey, size_t uiSizeInByte, xiiUInt64 uiSeed=0)
 Calculates the 64bit murmur hash of the given key.
 
template<size_t N>
static constexpr xiiUInt32 MurmurHash32String (const char(&str)[N], xiiUInt32 uiSeed=0)
 Calculates the 32bit murmur hash of a string constant at compile time. Encoding does not matter here.
 
static xiiUInt32 MurmurHash32String (xiiStringView sStr, xiiUInt32 uiSeed=0)
 Calculates the 32bit murmur hash of a string pointer during runtime. Encoding does not matter here.
 
static xiiUInt32 xxHash32 (const void *pKey, size_t uiSizeInByte, xiiUInt32 uiSeed=0)
 Calculates the 32bit xxHash of the given key.
 
static xiiUInt64 xxHash64 (const void *pKey, size_t uiSizeInByte, xiiUInt64 uiSeed=0)
 Calculates the 64bit xxHash of the given key.
 
template<size_t N>
static constexpr xiiUInt32 xxHash32String (const char(&str)[N], xiiUInt32 uiSeed=0)
 Calculates the 32bit xxHash of the given string literal at compile time.
 
template<size_t N>
static constexpr xiiUInt64 xxHash64String (const char(&str)[N], xiiUInt64 uiSeed=0)
 Calculates the 64bit xxHash of the given string literal at compile time.
 
static xiiUInt32 xxHash32String (xiiStringView sStr, xiiUInt32 uiSeed=0)
 Calculates the 32bit xxHash of a string pointer during runtime.
 
static xiiUInt64 xxHash64String (xiiStringView sStr, xiiUInt64 uiSeed=0)
 Calculates the 64bit xxHash of a string pointer during runtime.
 
template<size_t N>
static constexpr xiiUInt64 StringHash (const char(&str)[N], xiiUInt64 uiSeed=0)
 Calculates the hash of the given string literal at compile time.
 
static xiiUInt64 StringHash (xiiStringView sStr, xiiUInt64 uiSeed=0)
 Calculates the hash of a string pointer at runtime.
 
static constexpr xiiUInt32 StringHashTo32 (xiiUInt64 uiHash)
 Truncates a 64 bit string hash to 32 bit.
 
static constexpr xiiUInt32 CombineHashValues32 (xiiUInt32 ui0, xiiUInt32 ui1)
 Combines two 32 bit hash values into one.
 

Detailed Description

This class provides implementations of different hashing algorithms.

Member Function Documentation

◆ MurmurHash32String()

XII_ALWAYS_INLINE xiiUInt32 xiiHashingUtils::MurmurHash32String ( xiiStringView sStr,
xiiUInt32 uiSeed = 0 )
static

Calculates the 32bit murmur hash of a string pointer during runtime. Encoding does not matter here.

We cannot pass a string pointer directly since a string constant would be treated as pointer as well.

◆ StringHash()

XII_ALWAYS_INLINE xiiUInt64 xiiHashingUtils::StringHash ( xiiStringView sStr,
xiiUInt64 uiSeed = 0 )
static

Calculates the hash of a string pointer at runtime.

We cannot pass a string pointer directly since a string constant would be treated as pointer as well.

◆ StringHashTo32()

XII_ALWAYS_INLINE xiiUInt32 xiiHashingUtils::StringHashTo32 ( xiiUInt64 uiHash)
staticconstexpr

Truncates a 64 bit string hash to 32 bit.

This is necessary when a 64 bit string hash is used in a hash table (which only uses 32 bit indices).

◆ xxHash32String()

XII_ALWAYS_INLINE xiiUInt32 xiiHashingUtils::xxHash32String ( xiiStringView sStr,
xiiUInt32 uiSeed = 0 )
static

Calculates the 32bit xxHash of a string pointer during runtime.

We cannot pass a string pointer directly since a string constant would be treated as pointer as well.

◆ xxHash64String()

XII_ALWAYS_INLINE xiiUInt64 xiiHashingUtils::xxHash64String ( xiiStringView sStr,
xiiUInt64 uiSeed = 0 )
static

Calculates the 64bit xxHash of a string pointer during runtime.

We cannot pass a string pointer directly since a string constant would be treated as pointer as well.


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