Add key generation
[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         Pair(Pair<A, B> *p) :
17                 a(p->a),
18                 b(p->b) {
19         }
20
21         A getFirst() {
22                 return a;
23         }
24
25         B getSecond() {
26                 return b;
27         }
28 };
29
30 template<typename A, typename B>
31 inline unsigned int pairHashFunction(Pair<A, B> *p) {
32         return (p->getFirst() << 1) ^ p->getSecond();
33 }
34
35 template<typename A, typename B>
36 inline bool pairEquals(Pair<A, B> *a, Pair<A, B> *b) {
37         return (a->getFirst() == b->getFirst() ) && (a->getSecond() == b->getSecond());
38 }
39
40 inline unsigned int pairHashFunction(Pair<int64_t, int64_t> p) {
41         return (p.getFirst() << 1) ^ p.getSecond();
42 }
43
44 inline bool pairEquals(Pair<int64_t, int64_t> a, Pair<int64_t, int64_t> b) {
45         return (a.getFirst() == b.getFirst() ) && (a.getSecond() == b.getSecond());
46 }
47 #endif