#ifndef HASHING_H #define HASHING_H // We are making tables as pairs of strings and ints #include using namespace std; // Some prime table sizes. const unsigned int sizes[] = {11, 23, 47, 97, 197, 419, 853, 1709, 3407, 6947, 14009, 28649 }; class Hash { public: // Constructors Hash(); Hash(unsigned int size); // Destructors ~Hash(); // Insertion into the table bool insert(string toInsert); // Check for a value in the table bool search(string toFind); // Remove a value from the table bool remove(string toRemove); // Get the number of elements in the table int getSize(); // Get the current capacity of the table (note that the table // will resize when use is > 0.5 of capacity) int getTableSize(); // Print out to cout void printContents(); private: // The table itself pair* table; // The current index into the array "sizes" that tells us how big // our table is unsigned int curSizeIndex; // The number of elements in our table unsigned int curUsed; // The hash function for strings unsigned int hashString(string toHash); // A helper function for insertion bool insertHelper(pair* table, string toInsert); }; #endif