algorithms Namespace
Definition
Functions Index
| constexpr uint32_t | fnv1a_hash (const std::string_view str) noexcept |
|
Computes a 32-bit FNV-1a hash from a string. More... | |
Functions
fnv1a_hash()
| nodiscard constexpr noexcept |
Computes a 32-bit FNV-1a hash from a string.
Implements the Fowler–Noll–Vo hash function (FNV-1a variant), a fast, non-cryptographic hash suitable for hash tables and identifier generation. The function is `constexpr`, enabling compile-time hashing of string literals.
## Algorithm
1. Initialize hash with FNV offset basis (2166136261) 2. For each byte: XOR with hash, then multiply by FNV prime (16777619)
## Usage
```cpp // Compile-time hash for type-safe IDs constexpr uint32_t id = fnv1a_hash("enemy_spawn");
// Used internally by strongly-typed ID constructors constexpr GameObjectPoolId POOL{"bullets"}; // calls fnv1a_hash ```
- Parameters
-
str The string view to hash.
- Returns
32-bit hash value.
This is not a cryptographic hash. Do not use for security purposes.
- See Also
GameObjectPoolId
- See Also
SpawnProfileId
- See Also
SpawnRuleId
Definition at line 50 of file algorithms.ixx.
Referenced by helios::core::data::StrongId< PrefabIdTag, uint32_t >::StrongId.
The documentation for this namespace was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.