nfx-hashing 0.1.2
Modern C++20 header-only hashing library with hardware acceleration
Loading...
Searching...
No Matches
Constants.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 nfx
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
31
32#pragma once
33
34#include <cstdint>
35
36namespace nfx::hashing::constants
37{
38 //=====================================================================
39 // Hash algorithm constants
40 //=====================================================================
41
42 //----------------------------------------------
43 // FNV-1a hash algorithm constants
44 //----------------------------------------------
45
47 inline constexpr uint32_t FNV_OFFSET_BASIS_32{ 0x811C9DC5 };
48
50 inline constexpr uint32_t FNV_PRIME_32{ 0x01000193 };
51
53 inline constexpr uint64_t FNV_OFFSET_BASIS_64{ 0xCBF29CE484222325ULL };
54
56 inline constexpr uint64_t FNV_PRIME_64{ 0x00000100000001B3ULL };
57
58 //----------------------------------------------
59 // Integer hashing constants
60 //----------------------------------------------
61
63 inline constexpr uint32_t KNUTH_MULTIPLIER_32{ 0x45d9f3b };
64
66 inline constexpr uint64_t WANG_MULTIPLIER_64_C1{ 0xbf58476d1ce4e5b9ull };
67
69 inline constexpr uint64_t WANG_MULTIPLIER_64_C2{ 0x94d049bb133111ebull };
70
71 //----------------------------------------------
72 // Hash combining constants
73 //----------------------------------------------
74
76 inline constexpr uint32_t GOLDEN_RATIO_32{ 0x9e3779b9 };
77
79 inline constexpr uint64_t GOLDEN_RATIO_64{ 0x9e3779b97f4a7c15ULL };
80
82 inline constexpr uint64_t MURMUR3_MULTIPLIER_C1{ 0xff51afd7ed558ccdULL };
83
85 inline constexpr uint64_t MURMUR3_MULTIPLIER_C2{ 0xc4ceb9fe1a85ec53ULL };
86
87 //----------------------------------------------
88 // Seed mixing constants
89 //----------------------------------------------
90
92 inline constexpr uint64_t SEED_MIX_MULTIPLIER_64{ 0x2545F4914F6CDD1DUL };
93} // namespace nfx::hashing::constants
constexpr uint32_t FNV_OFFSET_BASIS_32
FNV-1a 32-bit offset basis constant.
Definition Constants.h:47
constexpr uint32_t FNV_PRIME_32
FNV-1a 32-bit prime constant.
Definition Constants.h:50
constexpr uint64_t MURMUR3_MULTIPLIER_C2
MurmurHash3 second multiplicative constant for avalanche mixing.
Definition Constants.h:85
constexpr uint32_t GOLDEN_RATIO_32
Golden ratio constant for 32-bit hash combining (φ = 2^32 / golden_ratio).
Definition Constants.h:76
constexpr uint64_t FNV_OFFSET_BASIS_64
FNV-1a 64-bit offset basis constant.
Definition Constants.h:53
constexpr uint64_t WANG_MULTIPLIER_64_C2
Wang's second multiplicative constant for 64-bit integer hashing.
Definition Constants.h:69
constexpr uint64_t SEED_MIX_MULTIPLIER_64
Multiplicative constant for seed mixing.
Definition Constants.h:92
constexpr uint64_t FNV_PRIME_64
FNV-1a 64-bit prime constant.
Definition Constants.h:56
constexpr uint32_t KNUTH_MULTIPLIER_32
Knuth's multiplicative constant for 32-bit integer hashing.
Definition Constants.h:63
constexpr uint64_t MURMUR3_MULTIPLIER_C1
MurmurHash3 first multiplicative constant for avalanche mixing.
Definition Constants.h:82
constexpr uint64_t GOLDEN_RATIO_64
Golden ratio constant for 64-bit hash combining (φ = 2^64 / golden_ratio).
Definition Constants.h:79
constexpr uint64_t WANG_MULTIPLIER_64_C1
Wang's first multiplicative constant for 64-bit integer hashing.
Definition Constants.h:66