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;
55 void threadA(void *arg) {
56 IntWrapper *k1 = new IntWrapper(3), *k2 = new IntWrapper(5),
57 *k3 = new IntWrapper(1024), *k4 = new IntWrapper(1025);
58 IntWrapper *v1 = new IntWrapper(1024), *v2 = new IntWrapper(1025),
59 *v3 = new IntWrapper(73), *v4 = new IntWrapper(81);
62 val1 = table->get(k3);
66 void threadB(void *arg) {
67 IntWrapper *k1 = new IntWrapper(3), *k2 = new IntWrapper(5),
68 *k3 = new IntWrapper(1024), *k4 = new IntWrapper(1025);
69 IntWrapper *v1 = new IntWrapper(1024), *v2 = new IntWrapper(1025),
70 *v3 = new IntWrapper(73), *v4 = new IntWrapper(81);
73 val1 = table->get(k2);
76 void threadC(void *arg) {
77 IntWrapper *k1 = new IntWrapper(3), *k2 = new IntWrapper(5),
78 *k3 = new IntWrapper(1024), *k4 = new IntWrapper(1025);
79 IntWrapper *v1 = new IntWrapper(1024), *v2 = new IntWrapper(1025),
80 *v3 = new IntWrapper(73), *v4 = new IntWrapper(81);
83 val2 = table->get(k1);
86 void threadMain(void *arg) {
87 for (int i = 200; i < 300; i++) {
88 IntWrapper *k = new IntWrapper(i), *v = new IntWrapper(i * 2);
93 int user_main(int argc, char *argv[]) {
94 thrd_t t1, t2, t3, t4;
95 table = new cliffc_hashtable<IntWrapper, IntWrapper>();
100 thrd_create(&t1, threadA, NULL);
101 thrd_create(&t2, threadB, NULL);
102 //thrd_create(&t3, threadC, NULL);
103 //thrd_create(&t4, threadD, NULL);
111 cout << "val1: NULL" << endl;
113 cout << val1->get() << endl;
115 //MODEL_ASSERT(val1 == NULL || val1->get() == 2 || val1->get() == 81);
117 cout << "val2: NULL" << endl;
119 cout << val2->get() << endl;