/* Example 22.1 Hash Table Application Driver Author: Peter Brusilovsky */ #include #include "IntHT.h" void main(){ HashTable *myHT; int i, res; int key; myHT = createHT(10); while(1){ printf("\nHash Table manipulation:\n\n"); printf("1. Add\t\t"); printf("2. Check\n"); printf("3. Count\t"); printf("4. Print\n"); printf("5. End\n\n"); i = 0; scanf("%d",&i); if(i == 1) { printf("Key? "); scanf("%d",&key); if((res = addHash(myHT, key)) == 0) printf("Key %d added in\n", key); else if(res == -1) printf("Table is Full\n"); else printf("Duplicate key %d\n", key); } else if (i == 2) { printf("key? "); scanf("%d",&key); if(checkHash(myHT, key)) printf("Key %d found\n", key); else printf("Key %d not found\n", key); } else if (i == 3) { printf("%d elements in the table\n", hashCount(myHT)); } else if (i == 4) { printHash(myHT); } else { destroyHT(myHT); return; } } }