Parasol Planning Library (PPL)
Hash.h
Go to the documentation of this file.
1 #ifndef PMPL_HASH_H_
2 #define PMPL_HASH_H_
3 
4 #include <functional>
5 
6 
7 namespace std {
8 
19  template <typename T, typename U>
20  struct hash<std::pair<T, U>> {
21 
22  typedef std::pair<T, U> KeyPair;
23 
24  static constexpr size_t magicOffset = 0x9e3779b99e3779b9;
25 
26  size_t operator()(const KeyPair& _key) const noexcept {
27  static constexpr std::hash<T> hasher1;
28  static constexpr std::hash<U> hasher2;
29  auto h1 = hasher1(_key.first),
30  h2 = hasher2(_key.second);
31  return h2 + magicOffset + (h1 << 6) + (h1 >> 2);
32  }
33 
34  };
35 
36 
37 }
38 
39 #endif
size_t operator()(const KeyPair &_key) const noexcept
Definition: Hash.h:26
std::pair< T, U > KeyPair
Definition: Hash.h:22