4 #include "hashmap_wildcard.h"
11 void printKey(Key *key) {
13 printf("pos = (%d, %d, %d)\n", key->x, key->y, key->z);
15 printf("pos = NULL\n");
18 void printValue(Value *value) {
20 printf("velocity = (%d, %d, %d)\n", value->vX, value->vY, value->vZ);
22 printf("velocity = NULL\n");
25 // Key(3, 2, 6) & Key(1, 3, 3) are hashed to the same slot -> 4
26 // Key(1, 1, 1) & Key(3, 2, 2) are hashed to the same slot -> 0
27 // Key(2, 4, 1) & Key(3, 4, 2) are hashed to the same slot -> 3
28 // Key(3, 4, 5) & Key(1, 4, 3) are hashed to the same slot -> 5
31 void threadA(void *arg) {
32 Key *k1 = new Key(3, 2, 6);
33 Key *k2 = new Key(1, 1, 1);
34 Value *v1 = new Value(10, 10, 10);
35 Value *r1 = table->put(k1, v1);
37 Value *r2 = table->get(k2);
38 //printf("Thrd A:\n");
42 void threadB(void *arg) {
43 Key *k1 = new Key(3, 2, 6);
44 Key *k2 = new Key(1, 1, 1);
45 Value *v2 = new Value(30, 40, 50);
46 Value *r3 = table->put(k2, v2);
48 Value *r4 = table->get(k1);
53 int user_main(int argc, char *argv[]) {
55 Key *k1 = new Key(3, 2, 6);
56 Key *k2 = new Key(1, 1, 1);
57 Value *v1 = new Value(111, 111, 111);
58 Value *v2 = new Value(222, 222, 222);
64 thrd_create(&t1, threadA, NULL);
65 thrd_create(&t2, threadB, NULL);