minor fix
[cdsspec-compiler.git] / benchmark / cliffc-hashtable / simplified_cliffc_hashtable.cc
1 #include <iostream>
2
3 #include "simplified_cliffc_hashtable.h"
4
5 using namespace std;
6
7 template<typename TypeK, typename TypeV>
8 slot* const cliffc_hashtable<TypeK, TypeV>::MATCH_ANY = new slot(false, NULL);
9
10 template<typename TypeK, typename TypeV>
11 slot* const cliffc_hashtable<TypeK, TypeV>::NO_MATCH_OLD = new slot(false, NULL);
12
13 template<typename TypeK, typename TypeV>
14 slot* const cliffc_hashtable<TypeK, TypeV>::TOMBPRIME = new slot(true, NULL);
15
16 template<typename TypeK, typename TypeV>
17 slot* const cliffc_hashtable<TypeK, TypeV>::TOMBSTONE = new slot(false, NULL);
18
19
20 class IntWrapper {
21         private:
22             int _val;
23                 public:
24
25                 IntWrapper(int val) : _val(val) {}
26
27                 IntWrapper() : _val(0) {}
28
29                 IntWrapper(IntWrapper& copy) : _val(copy._val) {}
30
31                 int get() {
32                         return _val;
33                 }
34
35                 int hashCode() {
36                         return _val;
37                 }
38
39                 bool equals(const shared_ptr<void> another) {
40                         if (another == NULL)
41                                 return false;
42                         shared_ptr<IntWrapper> ptr =
43                                 static_pointer_cast<IntWrapper>(another);
44                         return ptr->_val == _val;
45                 }
46 };
47
48 int main(int argc, char *argv[]) {
49         cliffc_hashtable<IntWrapper, IntWrapper> table;
50         IntWrapper k1(3), k2(4), v1(1), v2(2);
51         
52
53         table.put(k1, v1);
54         table.put(k2, v2);
55         cout << table.get(k2)->get() << endl;
56         return 1;
57 }