1 #ifndef COMPARE_KEY_H_
2 #define COMPARE_KEY_H_
3 
4 #include <iostream>
5 #include <map>
6 
7 namespace qflow {
8 
9 struct Key2i
10 {
Key2iqflow::Key2i11 	Key2i(int x, int y)
12 		: key(std::make_pair(x, y))
13 	{}
operator ==qflow::Key2i14 	bool operator==(const Key2i& other) const
15 	{
16 		return key == other.key;
17 	}
operator <qflow::Key2i18 	bool operator<(const Key2i& other) const
19 	{
20 		return key < other.key;
21 	}
22 	std::pair<int, int> key;
23 };
24 
25 struct Key3i
26 {
Key3iqflow::Key3i27 	Key3i(int x, int y, int z)
28 		: key(std::make_pair(x, std::make_pair(y, z)))
29 	{}
operator ==qflow::Key3i30 	bool operator==(const Key3i& other) const
31 	{
32 		return key == other.key;
33 	}
operator <qflow::Key3i34 	bool operator<(const Key3i& other) const
35 	{
36 		return key < other.key;
37 	}
38 	std::pair<int, std::pair<int, int> > key;
39 };
40 
41 struct Key3f
42 {
Key3fqflow::Key3f43 	Key3f(double x, double y, double z, double threshold)
44 		: key(std::make_pair(x / threshold, std::make_pair(y / threshold, z / threshold)))
45 	{}
operator ==qflow::Key3f46 	bool operator==(const Key3f& other) const
47 	{
48 		return key == other.key;
49 	}
operator <qflow::Key3f50 	bool operator<(const Key3f& other) const
51 	{
52 		return key < other.key;
53 	}
54 	std::pair<int, std::pair<int, int> > key;
55 };
56 
57 struct KeySorted2i
58 {
KeySorted2iqflow::KeySorted2i59 	KeySorted2i(int x, int y)
60 		: key(std::make_pair(x, y))
61 	{
62 		if (x > y)
63 			std::swap(key.first, key.second);
64 	}
operator ==qflow::KeySorted2i65 	bool operator==(const KeySorted2i& other) const
66 	{
67 		return key == other.key;
68 	}
operator <qflow::KeySorted2i69 	bool operator<(const KeySorted2i& other) const
70 	{
71 		return key < other.key;
72 	}
73 	std::pair<int, int> key;
74 };
75 
76 struct KeySorted3i
77 {
KeySorted3iqflow::KeySorted3i78 	KeySorted3i(int x, int y, int z)
79 		: key(std::make_pair(x, std::make_pair(y, z)))
80 	{
81 		if (key.first > key.second.first)
82 			std::swap(key.first, key.second.first);
83 		if (key.first > key.second.second)
84 			std::swap(key.first, key.second.second);
85 		if (key.second.first > key.second.second)
86 			std::swap(key.second.first, key.second.second);
87 	}
operator ==qflow::KeySorted3i88 	bool operator==(const Key3i& other) const
89 	{
90 		return key == other.key;
91 	}
operator <qflow::KeySorted3i92 	bool operator<(const Key3i& other) const
93 	{
94 		return key < other.key;
95 	}
96 	std::pair<int, std::pair<int, int> > key;
97 };
98 
99 
100 } // namespace qflow
101 
102 #endif
103