Plasma Engine  2.0
Loading...
Searching...
No Matches
plHashingUtils Class Reference

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

#include <HashingUtils.h>

Public Member Functions

template<size_t N>
constexpr PL_ALWAYS_INLINE plUInt32 MurmurHash32String (const char(&str)[N], plUInt32 uiSeed)
 
template<size_t N>
constexpr PL_ALWAYS_INLINE plUInt64 StringHash (const char(&str)[N], plUInt64 uiSeed)
 
template<size_t N>
constexpr PL_ALWAYS_INLINE plUInt32 xxHash32String (const char(&str)[N], plUInt32 uiSeed)
 
template<size_t N>
constexpr PL_ALWAYS_INLINE plUInt64 xxHash64String (const char(&str)[N], plUInt64 uiSeed)
 

Static Public Member Functions

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

Detailed Description

This class provides implementations of different hashing algorithms.

Member Function Documentation

◆ MurmurHash32String()

PL_ALWAYS_INLINE plUInt32 plHashingUtils::MurmurHash32String ( plStringView sStr,
plUInt32 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()

PL_ALWAYS_INLINE plUInt64 plHashingUtils::StringHash ( plStringView sStr,
plUInt64 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()

PL_ALWAYS_INLINE plUInt32 plHashingUtils::StringHashTo32 ( plUInt64 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()

PL_ALWAYS_INLINE plUInt32 plHashingUtils::xxHash32String ( plStringView sStr,
plUInt32 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()

PL_ALWAYS_INLINE plUInt64 plHashingUtils::xxHash64String ( plStringView sStr,
plUInt64 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: