#include "dictionary.h" // Dictionary implemented with a hash table template class hashdict : public Dictionary { private: Elem* HT; // The hash table int M; // Size of HT int currcnt; // The current number of elements in HT Elem EMPTY; // User-supplied value for an empty slot int p(Key K, int i) const // Probe using linear probing { return i; } int h(int x) const { return x % M; } // Poor hash function int h(char* x) const { // Hash function for character keys int i, sum; for (sum=0, i=0; x[i] != '\0'; i++) sum += (int) x[i]; return(sum % M); } bool hashInsert(const Elem&); bool hashSearch(const Key&, Elem&) const; public: hashdict(int sz, Elem e){ // e defines an EMPTY slot M = sz; EMPTY = e; currcnt = 0; HT = new Elem[sz]; // Make HT of size sz for (int i=0; i