A Hash Table Implementation

The following header file and implementation file declares and defines a template hash map class. The class takes four template parameters. The first is the key type and the second is the value type. The third parameter specifies the hash function and the fourth parameter specifies how to compare two objects of the key's data type.

· hashmap.h - declaration of class HashMap

· hashmap.cpp - definition of class HashMap

The return type of the search member function of class HashMap is an STL class that we have not yet encountered. Function search returns an object of type pair. Class pair is an STL class that contains two data members. These members are named first and second. This class is used often by functions that need to return more than one piece of data. The search member function needs to return whether or not the item was found and what position it was found in. Thus, function search returns an object of type class pair<bool, int>.

The file hash-driver.cpp demonstrates use of class HashMap and its member functions.