free(node);
}
+void my_print(void* o) {
+ Node* n = (Node *) o;
+ printf("%s", n->name);
+}
+
bool my_ptr_equal(const void* a, const void* b) {
const Node* nodea = a;
const Node* nodeb = b;
fclose(fp);
printf("Loaded %d words into the table.\n", numwords);
+ hash_table_print(table);
+ hash_table_set_print_func(table, my_print);
+ hash_table_print(table);
/*
uint32_t good_guesses = 0;
}
hash_table_destroy(table);
+
+ table = hash_table_create(str_hash, str_equal);
+ char *names[] = { "Adam", "Eva", "Abraham", "Kain", "Abel", NULL };
+ for (int i = 0; names[i]; i++) {
+ void* name = names[i];
+ hash_table_insert(table, name, strdup(name));
+ }
+ hash_table_iter_init(&iter, table);
+ while (hash_table_iter_next(&iter, &key, &value)) {
+ printf("Key: %p value: %s\n", (char*)key, (char*)value);
+ }
+ data = hash_table_delete(table, (void*) names[4]);
+ printf("Deleted: [%p] %s\n", data, (char*) data);
+ free(data);
+ hash_table_replace(table, (void*) names[4], strdup(names[4]));
+ hash_table_replace(table, (void*) names[4], strdup("Johannes"));
+ hash_table_iter_init(&iter, table);
+ while (hash_table_iter_next(&iter, &key, &value)) {
+ printf("Key: %p value: %s\n", (char*)key, (char*)value);
+ }
+
+ hash_table_destroy(table);
}