-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode_type_hash.hpp
More file actions
31 lines (24 loc) · 833 Bytes
/
node_type_hash.hpp
File metadata and controls
31 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// =========================================================
// FILE: src/state/jmt/node_type_hash.hpp
// PURPOSE: std::hash specialization for NodeKey
// CRITICAL: Required for TreeCache (unordered_map)
// =========================================================
#pragma once
#include "node_type.hpp"
#include <functional>
namespace std {
template <>
struct hash<glofica::xook::NodeKey> {
size_t operator()(const glofica::xook::NodeKey& k) const noexcept {
// Hash combine: version XOR path
size_t h1 = std::hash<uint64_t>{}(k.version);
// Hash nibble path bytes
size_t h2 = 0;
const auto& bytes = k.nibble_path.bytes();
for (const auto& byte : bytes) {
h2 = h2 * 31 + byte;
}
return h1 ^ (h2 << 1);
}
};
} // namespace std