int main() { int capacity = 11, i; HashTablePtr t = newHashTable(capacity, hashInt, compare); HashNodePtr node; putIntoHashTable(t, 1, 1); putIntoHashTable(t, 2, 2); putIntoHashTable(t, 3, 3); putIntoHashTable(t, 4, 4); putIntoHashTable(t, 5, 5); printHashTable(t); for(i = 0; i <= 5; i++) { HashNodePtr node = getFromHashTable(t, i); if(node) { printf("key %d values %d\n", node->key, node->value); } else { printf("cann't find key %d\n", i); } } for(i = 11; i <= 16; i++) { HashNodePtr node = getFromHashTable(t, i); if(node) { printf("key %d values %d\n", node->key, node->value); } else { printf("cann't find key %d\n", i); } } removeFromHashTable(t, 2); removeFromHashTable(t, 3); printHashTable(t); putIntoHashTable(t, 2, 2); putIntoHashTable(t, 13, 13); putIntoHashTable(t, 24, 24); printHashTable(t); removeFromHashTable(t, 2); printHashTable(t); node = getFromHashTable(t, 13); printf("key %d values %d\n", node->key, node->value); node = getFromHashTable(t, 24); printf("key %d values %d\n", node->key, node->value); putIntoHashTable(t, 35, 35); printHashTable(t); freeHashTable(t); return 0; }
void add(int value) { printf("add %d into hash table\n", value); putIntoHashTable(value); }