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 equals(const void *another) {
43 (IntWrapper*) another;
44 return ptr->_val == _val;
48 cliffc_hashtable<IntWrapper, IntWrapper> *table;
49 IntWrapper *val1, *val2;
51 void threadA(void *arg) {
53 IntWrapper k1(3), k2(5), k3(1024), k4(1025);
54 IntWrapper v1(1), v2(2), v3(73), v4(81);
57 val1 = table->get(k3);
60 for (int i = 200; i < 205; i++) {
61 IntWrapper k(i), v(i * 2);
66 void threadB(void *arg) {
67 IntWrapper k1(3), k2(5), k3(1024), k4(1025);
68 IntWrapper v1(1), v2(2), v3(73), v4(81);
71 val1 = table->get(k2);
74 void threadC(void *arg) {
75 IntWrapper k1(3), k2(5), k3(1024), k4(1025);
76 IntWrapper v1(1), v2(2), v3(73), v4(81);
79 val2 = table->get(k1);
82 void threadD(void *arg) {
83 IntWrapper k1(3), k2(5), k3(1024), k4(1025);
84 IntWrapper v1(1), v2(2), v3(73), v4(81);
87 val2 = table->get(k2);
90 int user_main(int argc, char *argv[]) {
91 thrd_t t1, t2, t3, t4;
92 table = new cliffc_hashtable<IntWrapper, IntWrapper>();
95 thrd_create(&t1, threadA, NULL);
96 thrd_create(&t2, threadB, NULL);
97 thrd_create(&t3, threadC, NULL);
98 //thrd_create(&t4, threadD, NULL);
106 cout << "val1: NULL" << endl;
108 cout << val1->get() << endl;
110 MODEL_ASSERT(val1 == NULL || val1->get() == 2 || val1->get() == 81);
112 cout << "val2: NULL" << endl;
114 cout << val2->get() << endl;