Compiles
[iotcloud.git] / version2 / src / C / Pair.h
index 127f9f8543eb7fdcb8d3067bab370e3953d12a22..81d5ebb3e388d117a0fd16e204362ea9df99a064 100644 (file)
@@ -3,23 +3,45 @@
 
 template<typename A, typename B>
 class Pair {
- private:
-  A a;
-  B b;
-       
- public:  
+private:
+       A a;
+       B b;
+
+public:
        Pair(A _a, B _b) :
-    a(_a),
-    b(_b) {
+               a(_a),
+               b(_b) {
        }
-  
+
+ Pair(Pair<A, B> * p) :
+               a(p->a),
+                       b(p->b) {
+               }
+               
        A getFirst() {
                return a;
        }
-  
+
        B getSecond() {
                return b;
        }
 };
 
+template<typename A, typename B>
+inline unsigned int pairHashFunction(Pair<A, B> * p) {
+       return (p->getFirst() << 1) ^ p->getSecond();
+}
+
+template<typename A, typename B>
+inline bool pairEquals(Pair<A, B> *a, Pair<A, B> *b) {
+       return (a->getFirst() == b->getFirst() ) && (a->getSecond() == b->getSecond());
+}
+
+inline unsigned int pairHashFunction(Pair<int64_t, int64_t> p) {
+       return (p.getFirst() << 1) ^ p.getSecond();
+}
+
+inline bool pairEquals(Pair<int64_t, int64_t> a, Pair<int64_t, int64_t> b) {
+       return (a.getFirst() == b.getFirst() ) && (a.getSecond() == b.getSecond());
+}
 #endif