Plasma Engine  2.0
Loading...
Searching...
No Matches
HashingUtils.h
1
2#pragma once
3
4#include <Foundation/Basics.h>
5
7class PL_FOUNDATION_DLL plHashingUtils
8{
9public:
11 static plUInt32 CRC32Hash(const void* pKey, size_t uiSizeInBytes); // [tested]
12
14 static plUInt32 MurmurHash32(const void* pKey, size_t uiSizeInByte, plUInt32 uiSeed = 0); // [tested]
15
17 static plUInt64 MurmurHash64(const void* pKey, size_t uiSizeInByte, plUInt64 uiSeed = 0); // [tested]
18
20 template <size_t N>
21 constexpr static plUInt32 MurmurHash32String(const char (&str)[N], plUInt32 uiSeed = 0); // [tested]
22
26 static plUInt32 MurmurHash32String(plStringView sStr, plUInt32 uiSeed = 0); // [tested]
27
29 static plUInt32 xxHash32(const void* pKey, size_t uiSizeInByte, plUInt32 uiSeed = 0); // [tested]
30
32 static plUInt64 xxHash64(const void* pKey, size_t uiSizeInByte, plUInt64 uiSeed = 0); // [tested]
33
35 template <size_t N>
36 constexpr static plUInt32 xxHash32String(const char (&str)[N], plUInt32 uiSeed = 0); // [tested]
37
39 template <size_t N>
40 constexpr static plUInt64 xxHash64String(const char (&str)[N], plUInt64 uiSeed = 0); // [tested]
41
45 static plUInt32 xxHash32String(plStringView sStr, plUInt32 uiSeed = 0); // [tested]
46
50 static plUInt64 xxHash64String(plStringView sStr, plUInt64 uiSeed = 0); // [tested]
51
53 template <size_t N>
54 constexpr static plUInt64 StringHash(const char (&str)[N], plUInt64 uiSeed = 0); // [tested]
55
59 static plUInt64 StringHash(plStringView sStr, plUInt64 uiSeed = 0); // [tested]
60
64 constexpr static plUInt32 StringHashTo32(plUInt64 uiHash);
65
67 constexpr static plUInt32 CombineHashValues32(plUInt32 ui0, plUInt32 ui1);
68};
69
73template <typename T>
75{
76 template <typename U>
77 static plUInt32 Hash(const U& value);
78
79 template <typename U>
80 static bool Equal(const T& a, const U& b);
81};
82
83#include <Foundation/Algorithm/Implementation/HashingMurmur_inl.h>
84#include <Foundation/Algorithm/Implementation/HashingUtils_inl.h>
85#include <Foundation/Algorithm/Implementation/HashingXxHash_inl.h>
This class provides implementations of different hashing algorithms.
Definition HashingUtils.h:8
static constexpr plUInt64 xxHash64String(const char(&str)[N], plUInt64 uiSeed=0)
Calculates the 64bit xxHash of the given string literal at compile time.
static constexpr plUInt32 xxHash32String(const char(&str)[N], plUInt32 uiSeed=0)
Calculates the 32bit xxHash of the given string literal at compile time.
static constexpr plUInt64 StringHash(const char(&str)[N], plUInt64 uiSeed=0)
Calculates the hash of the given string literal at compile time.
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.
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Helper struct to calculate the Hash of different types.
Definition HashingUtils.h:75