#ifndef HashTable_SEEN__ #define HashTable_SEEN__ /////// File: HashTable.h /////// // Each entry of table has a key which is a string // The key string is unique: two entries are regarded to // be the same if they have the same key // A function getkey that extracts a key from an entry must // also be defined // Usage: HashTable ht(n) // gives a hash table of employees, size 2^n, [n=8] // getkey can return the SS No. for example #include "List.h" #define CS const typedef unsigned Uint; template class HashTable { public: enum {noe, H_MULT=2640025017u};// no entry and default multiplier HashTable(Uint k = 8, // constructor Uint m = H_MULT); void put(T& a); // enters record a int get(CS char *key, T& r); // returns record in rval int rid(CS char* key); // removes a record int is_on(char* key); // checks if record is on table Uint length() { return len; } // returns length of table ~HashTable(); private: List** ht; // table of linked lists Uint hash(CS char*); // builtin hash function static int on_list // record on list l? (List& l, char* key); Uint len; // No. of entries on table Uint mult; // hash multiplier Uint bits; // hash table 2^bits }; template char* getkey(T& item); // supplied key function Uint str_to_u(const char *str); // common utility function #endif