// This should be your hash.h file, the header file of declarations // YOUR NAMES HERE <==> CHANGE THIS! // Originally created by Jiang Zheng and R. P. Futrelle for COM1201, Spring 2000, MP#3. using namespace std; // Can be omitted from the .cpp files since it's here. // The info or data in the table can be just a string typedef string Info; // Declaration of class Node, an item in the LinkedList class Node { public: int key; // key value, e.g., 61 Info info; // information, a string, e.g., "Australia" Node* next; // next Node public: Node(int k,Info i); // constructor (destructor optional) void print(); // print one node to cout void writeToFile(fstream&); / write one node to a file }; // LinkedList is the element of the hash array that points to the first node // on any list attached to an array element. class LinkedList { public: Node* head; // head of the list int length; // the length of the list public: LinkedList(); //constructor (destructor optional) void insertNode(Node* node); // insert a node to the list // void deleteNode(int key); // delete a node from the list (optional) Node* searchNode(int key); // search a key value int getLength(); // allows you to collect statistics void print(); // print one entire list to cout void writeToFile(fstream&); // ditto to a file }; // The size of the hashtable. You can use some other size. const int SIZE = 5 // a prime number (please don't use #define) // The HashTable contains the hash array and the accessor functions. class HashTable { public: LinkedList* list[SIZE]; // Array of heads of any possible attached lists public: HashTable(); // constructor (no destructor needed) int hash(int key); // hash function, to be defined by you void insertH(Node* node); // insert a node into the HashTable Node* searchH(int key); // search a key value in the HashTable void deleteH(int key); // delete a node from the HashTable (optional) void print(); // print entire hash table to cout by array elements void writeToFile(fstream&); // ditto to file void readFromFile(fstream&); // read key/info pairs and insert each as they are read (optional) };