Generic hash function object supporting multiple types.
More...
#include <hash.h>
|
template<typename T > |
static void | hashCombine (u_integer &seed, const T &value) noexcept |
| Combines a hash value with another value's hash.
|
|
static u_integer | fnv1a (const byte *data, u_integer size) noexcept |
| FNV-1a hash implementation for raw byte data.
|
|
template<typename T , typename... Rest> |
static void | hashCombine (u_integer &seed, const T &value, const Rest &... rest) noexcept |
| Combines multiple hash values into one.
|
|
template<typename T > |
static u_integer | hashFunc (const T &t) noexcept |
| Default hash function fallback.
|
|
template<typename T >
requires ExtendsOf<hashable<T>, T> |
static u_integer | hashFunc (const T &t) noexcept |
|
template<std::integral T> |
static u_integer | hashFunc (const T &t) noexcept |
| Hash function specialization for integral types.
|
|
template<typename T > |
static u_integer | hashFunc (T *const &t) noexcept |
| Hash function for pointers.
|
|
static u_integer | hashFunc (const std::nullptr_t &null) noexcept |
| Hash function for nullptr.
|
|
static u_integer | hashFunc (const char &t) noexcept |
| Hash function for single character.
|
|
static u_integer | hashFunc (const char *str) noexcept |
| Hash function for C-style strings.
|
|
static u_integer | hashFunc (const std::string &str) noexcept |
| Hash function for std::string.
|
|
|
static constexpr u_integer | FNV_OFFSET_BASIS = 0x811C9DC5 |
| FNV-1a initial offset value (0x811C9DC5)
|
|
static constexpr u_integer | FNV_32_PRIME = 0x01000193 |
| FNV-1a prime multiplier (0x01000193)
|
|
|
template<typename > |
class | hashable |
|
template<typename TYPE>
class original::hash< TYPE >
Generic hash function object supporting multiple types.
- Template Parameters
-
TYPE | The type for which the hash function object is defined |
Provides:
- FNV-1a hash algorithm implementation
- Specialized hash functions for common types
- Fallback implementations for arbitrary types
- Consistent hashing interface via operator()
Supported Types:
- Integral types (direct casting)
- Pointers (address-based hashing)
- Strings (FNV-1a over characters)
- Trivially copyable types (byte-wise hashing)
- Types implementing hashable interface
Example Usage:
Generic hash function object supporting multiple types.
Definition hash.h:62
std::uint32_t u_integer
32-bit unsigned integer type for sizes and indexes
Definition config.h:263
◆ fnv1a()
FNV-1a hash implementation for raw byte data.
- Parameters
-
data | Pointer to byte array |
size | Number of bytes to hash |
- Returns
- Computed hash value
- Note
- This is the fundamental hashing operation used by other specializations
◆ hashCombine() [1/2]
template<typename TYPE >
template<typename T >
Combines a hash value with another value's hash.
- Template Parameters
-
T | Type of the value to combine |
- Parameters
-
seed | Current hash value (modified in-place) |
value | Value whose hash to combine |
◆ hashCombine() [2/2]
template<typename TYPE >
template<typename T , typename... Rest>
Combines multiple hash values into one.
- Template Parameters
-
T | First value type |
Rest | Remaining value types |
- Parameters
-
seed | Current hash value (modified in-place) |
value | First value to combine |
rest | Remaining values to combine |
◆ hashFunc() [1/7]
Hash function for single character.
- Parameters
-
- Returns
- Integer value of the character
◆ hashFunc() [2/7]
Hash function for C-style strings.
- Parameters
-
str | Null-terminated string |
- Returns
- Computed FNV-1a hash
- Note
- Handles nullptr by returning 0
◆ hashFunc() [3/7]
Hash function for nullptr.
- Parameters
-
- Returns
- 0 as the hash value
◆ hashFunc() [4/7]
Hash function for std::string.
- Parameters
-
- Returns
- Computed FNV-1a hash
◆ hashFunc() [5/7]
template<typename TYPE >
template<typename T >
Default hash function fallback.
- Template Parameters
-
- Parameters
-
- Returns
- Hash value
For trivially copyable types: uses byte-wise FNV-1a For other types: falls back to address hashing
◆ hashFunc() [6/7]
template<typename TYPE >
template<std::integral T>
Hash function specialization for integral types.
- Template Parameters
-
- Parameters
-
- Returns
- The cast hash value
◆ hashFunc() [7/7]
template<typename TYPE >
template<typename T >
Hash function for pointers.
- Template Parameters
-
- Parameters
-
- Returns
- Hash value based on address
◆ operator()()
Hash function object call operator.
- Parameters
-
- Returns
- Result of hashFunc
- Note
- Provides consistent interface for use in STL containers
The documentation for this class was generated from the following file: