Maze Builder Docs 6.0.1
Loading...
Searching...
No Matches
hash_funcs.h
Go to the documentation of this file.
1#ifndef HASH_FUNCS_H
2#define HASH_FUNCS_H
3
4#include <utility>
5#include <tuple>
6#include <functional>
7
8namespace mazes {
9
11
14struct uni_hash {
19 template <class T1>
20 std::size_t operator()(const T1& p) const {
21 auto hash1 = std::hash<T1>{}(p);
22 auto hash2 = std::hash<T1>{}(p) + 0x9e3779b9;
23 return hash1 ^ (hash2 + 0x9e3779b9 + (hash1 << 6) + (hash1 >> 2));
24 }
25};
26
29struct pair_hash {
30
36 template <class T1, class T2>
37 std::size_t operator()(const std::pair<T1, T2>& p) const {
38 auto hash1 = std::hash<T1>{}(p.first);
39 auto hash2 = std::hash<T2>{}(p.second);
40 return hash1 ^ hash2;
41 }
42}; // pair_hash
43
46struct tri_hash {
53 template <class T1, class T2, class T3>
54 std::size_t operator()(const std::tuple<T1, T2, T3>& p) const {
55 auto hash1 = std::hash<T1>{}(std::get<0>(p));
56 auto hash2 = std::hash<T2>{}(std::get<1>(p));
57 auto hash3 = std::hash<T3>{}(std::get<2>(p));
58 return hash1 ^ hash2 ^ hash3;
59 }
60};
61
62} // namespace mazes
63
64#endif // HASH_FUNCS_H
Namespace for the maze builder.
Definition algo_interface.h:9
Hashing function to store a block's (x, z) position.
Definition hash_funcs.h:29
std::size_t operator()(const std::pair< T1, T2 > &p) const
Hash function for a pair.
Definition hash_funcs.h:37
Hashing function to store a block's (x, y, z) position.
Definition hash_funcs.h:46
std::size_t operator()(const std::tuple< T1, T2, T3 > &p) const
Hash function for a tuple.
Definition hash_funcs.h:54
A hash function object for a single value.
Definition hash_funcs.h:14
std::size_t operator()(const T1 &p) const
Hash function for a single.
Definition hash_funcs.h:20