4da3bf7f1a06f605817a043922ab4545b8b3546f
[iotcloud.git] / version2 / src / C / Pair.h
1 #ifndef PAIR_H
2 #define PAIR_H
3
4 template<typename A, typename B>
5 class Pair {
6 private:
7         A a;
8         B b;
9
10 public:
11         Pair(A _a, B _b) :
12                 a(_a),
13                 b(_b) {
14         }
15
16         A getFirst() {
17                 return a;
18         }
19
20         B getSecond() {
21                 return b;
22         }
23 };
24
25 template<typename A, typename B>
26 inline unsigned int pairHashFunction(Pair<A, B> p) {
27         return (p.getFirst() << 1) ^ p.getSecond();
28 }
29
30 template<typename A, typename B>
31 inline bool pairEquals(Pair<A, B> a, Pair<A, B> b) {
32         return ( a.getFirst() == b.getFirst() ) && (a.getSecond() == b.getSecond());
33 }
34
35 inline unsigned int pairHashFunction(Pair<int64_t, int64_t> p) {
36         return (p.getFirst() << 1) ^ p.getSecond();
37 }
38
39 inline bool pairEquals(Pair<int64_t, int64_t> a, Pair<int64_t, int64_t> b) {
40         return ( a.getFirst() == b.getFirst() ) && (a.getSecond() == b.getSecond());
41 }
42 #endif