-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_key.h
43 lines (33 loc) · 1.12 KB
/
index_key.h
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
32
33
34
35
36
37
38
39
40
41
42
43
#include <string>
#include <unordered_map>
#ifndef TYPES
#define TYPES
#include "types.h"
#endif
struct IndexedRulesKey{
std::string left, right;
bool operator==(const IndexedRulesKey &other) const {
return left == other.left && right == other.right;
}
std::string str(){
return "\"" + left + "\", "+ "\"" + right + "\", ";
}
};
namespace std {
template <>
struct hash<IndexedRulesKey>
{
std::size_t operator()(const IndexedRulesKey& k) const
{
using std::size_t;
using std::hash;
using std::string;
// Compute individual hash values for first,
// second and third and combine them using XOR
// and bit shifting:
return ((hash<string>()(k.left)
^ (hash<string>()(k.right) << 1)) >> 1);
}
};
}
typedef std::unordered_map<IndexedRulesKey, StringVector> IndexedRules;