//  File: hmain.C
//
//  Testing the HashTable class

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include "hash.h"

main() {
   HashTable H(100) ;
   StudentRecord rec ;

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

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

   // Exercise the HashTable routines
   //
   cout << "\nTesting the Find function\n" << endl ;

   if (H.find(1234567, rec)) {
      cout << "Found: " << rec << endl ;
   } else {
      cout << "Not found!" << endl ;
   }

   if (H.find(7654321, rec)) {
      cout << "Found: " << rec << endl ;
   } else {
      cout << "Not found!" << endl ;
   }

   int n = H.extract(1234567) ;
   cout << "Removed " << n << " item(s)" << endl ;

   H.dump() ;
}
