8 void printKey(Key *key) {
10 printf("pos = (%d, %d, %d)\n", key->x, key->y, key->z);
12 printf("pos = NULL\n");
15 void printValue(Value *value) {
17 printf("velocity = (%d, %d, %d)\n", value->vX, value->vY, value->vZ);
19 printf("velocity = NULL\n");
22 // Key(3, 2, 6) & Key(1, 3, 3) are hashed to the same slot -> 4
23 // Key(1, 1, 1) & Key(3, 2, 2) are hashed to the same slot -> 0
24 // Key(2, 4, 1) & Key(3, 4, 2) are hashed to the same slot -> 3
25 // Key(3, 4, 5) & Key(1, 4, 3) are hashed to the same slot -> 5
28 void threadA(void *arg) {
29 Key *k1 = new Key(3, 2, 6);
30 Key *k2 = new Key(1, 1, 1);
31 Value *v1 = new Value(10, 10, 10);
32 Value *r1 = table->put(k1, v1);
34 Value *r2 = table->get(k2);
35 //printf("Thrd A:\n");
39 void threadB(void *arg) {
40 Key *k1 = new Key(3, 2, 6);
41 Key *k2 = new Key(1, 1, 1);
42 Value *v2 = new Value(30, 40, 50);
43 Value *r3 = table->put(k2, v2);
45 Value *r4 = table->get(k1);
50 int user_main(int argc, char *argv[]) {
53 Key *k1 = new Key(1, 3, 3);
54 Key *k1_prime = new Key(3, 2, 6);
55 Key *k2 = new Key(3, 2, 2);
56 Key *k2_prime = new Key(1, 1, 1);
57 Value *v1 = new Value(111, 111, 111);
58 Value *v2 = new Value(222, 222, 222);
62 printf("Key1: %d\n", table->hashKey(k1) % table->capacity);
63 printf("Key1': %d\n", table->hashKey(k1_prime) % table->capacity);
64 printf("Key2: %d\n", table->hashKey(k2) % table->capacity);
65 printf("Key2': %d\n", table->hashKey(k2_prime) % table->capacity);
67 thrd_create(&t1, threadA, NULL);
68 thrd_create(&t2, threadB, NULL);