3 #include "cliffc_hashtable.h"
7 template<typename TypeK, typename TypeV>
8 slot* const cliffc_hashtable<TypeK, TypeV>::MATCH_ANY = new slot(false, NULL);
10 template<typename TypeK, typename TypeV>
11 slot* const cliffc_hashtable<TypeK, TypeV>::NO_MATCH_OLD = new slot(false, NULL);
13 template<typename TypeK, typename TypeV>
14 slot* const cliffc_hashtable<TypeK, TypeV>::TOMBPRIME = new slot(true, NULL);
16 template<typename TypeK, typename TypeV>
17 slot* const cliffc_hashtable<TypeK, TypeV>::TOMBSTONE = new slot(false, NULL);
25 IntWrapper(int val) : _val(val) {}
27 IntWrapper() : _val(0) {}
29 IntWrapper(IntWrapper& copy) : _val(copy._val) {}
39 bool operator==(const IntWrapper& rhs) {
43 bool equals(const void *another) {
47 (IntWrapper*) another;
48 return ptr->_val == _val;
52 cliffc_hashtable<IntWrapper, IntWrapper> *table;
53 IntWrapper *val1, *val2;
54 IntWrapper *k0, *k1, *k2, *k3, *k4, *k5;
55 IntWrapper *v0, *v1, *v2, *v3, *v4, *v5;
57 void threadA(void *arg) {
62 val1 = table->get(k3);
64 model_print("val1: %d\n", val1->_val);
66 model_print("val1: NULL\n");*/
71 void threadB(void *arg) {
77 void threadMain(void *arg) {
78 val1 = table->get(k1);
79 val2 = table->get(k2);
81 model_print("val1: %d\n", val1->_val);
83 model_print("val1: NULL\n");
85 model_print("val2: %d\n", val2->_val);
87 model_print("val2: NULL\n");
90 int user_main(int argc, char *argv[]) {
92 table = new cliffc_hashtable<IntWrapper, IntWrapper>(2);
93 k1 = new IntWrapper(3);
94 k2 = new IntWrapper(5);
95 k3 = new IntWrapper(11);
96 k4 = new IntWrapper(7);
97 k5 = new IntWrapper(13);
99 v1 = new IntWrapper(1024);
100 v2 = new IntWrapper(47);
101 v3 = new IntWrapper(73);
102 v4 = new IntWrapper(81);
103 v5 = new IntWrapper(99);
105 v0 = new IntWrapper(2048);
108 model_print("hey\n");
109 thrd_create(&t1, threadA, NULL);
110 thrd_create(&t2, threadB, NULL);
117 cout << "val1: NULL" << endl;
119 cout << val1->get() << endl;
121 //MODEL_ASSERT(val1 == NULL || val1->get() == 2 || val1->get() == 81);
123 cout << "val2: NULL" << endl;
125 cout << val2->get() << endl;