BashSpark
Loading...
Searching...
No Matches
shell_hash.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <cstdint>
36#include <string>
37
38namespace bs {
46 struct shell_hash {
48 static constexpr std::uint64_t FNV_OFFSET = 1469598103934665603ull;
50 static constexpr std::uint64_t FNV_PRIME = 1099511628211ull;
51
52
69 std::uint64_t operator()(const std::string &sString) const noexcept {
70 std::uint64_t nHash = FNV_OFFSET;
71 for (const unsigned char cChar: sString) {
72 nHash ^= cChar;
73 nHash *= FNV_PRIME;
74 }
75 return nHash;
76 }
77 };
78
88 static constexpr std::uint64_t FNV_OFFSET = 1469598103934665603ull;
90 static constexpr std::uint64_t FNV_PRIME = 1099511628211ull;
91
92
109 std::uint64_t operator()(const std::string_view &sString) const noexcept {
110 std::uint64_t nHash = FNV_OFFSET;
111 for (const unsigned char cChar: sString) {
112 nHash ^= cChar;
113 nHash *= FNV_PRIME;
114 }
115 return nHash;
116 }
117 };
118
119}
BashSpark main namespace.
Definition command.h:39
Custom hash functor for strings using the 64-bit FNV-1a algorithm.
Definition shell_hash.h:86
static constexpr std::uint64_t FNV_PRIME
FVN prime.
Definition shell_hash.h:90
std::uint64_t operator()(const std::string_view &sString) const noexcept
Computes a 64-bit FNV-1a hash for a string.
Definition shell_hash.h:109
static constexpr std::uint64_t FNV_OFFSET
FVN offset.
Definition shell_hash.h:88
Custom hash functor for strings using the 64-bit FNV-1a algorithm.
Definition shell_hash.h:46
static constexpr std::uint64_t FNV_OFFSET
FVN offset.
Definition shell_hash.h:48
std::uint64_t operator()(const std::string &sString) const noexcept
Computes a 64-bit FNV-1a hash for a string.
Definition shell_hash.h:69
static constexpr std::uint64_t FNV_PRIME
FVN prime.
Definition shell_hash.h:50