/* File: hmain.C

   Testing the HashTable class
*/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "hash.h"

main() {
   HashTable *H ;
   ListItem *iptr ;

   printf("Make new HashTable\n") ;
   H = new HashTable(100) ;

   // Enter some data:
   //
   H->Insert(ListItem(1234567, "John Smith", "CMSC")) ;
   H->Insert(ListItem(24681012, "Jane Doe", "CMSC")) ;
   H->Insert(ListItem(135791113, "Joe Blow", "CMSC")) ;
   H->Insert(ListItem(314316598, "James Cameron", "FILM")) ;
   H->Insert(ListItem(874310457, "Isaac Asimov", "CHEM")) ;

   // Take a look at the table
   //
   H->dump() ;

   // Exercise the HashTable routines
   //
   printf("\nTesting the Find function\n\n") ;

   iptr = H->Find(1234567) ;
   if (iptr != NULL) {
      printf("Found: ") ;
      iptr->print() ;
      printf("\n") ;
      delete iptr ;
   } else {
      printf("Not found!\n") ;
   }

   iptr = H->Find(7654321) ;
   if (iptr != NULL) {
      printf("Found: ") ;
      iptr->print() ;
      printf("\n") ;
      delete iptr ;
   } else {
      printf("Not found!\n") ;
   }

   H->Delete(1234567) ;

   H->dump() ;
   delete H ;
}
