CPSC170A
Fundamentals of Computer Science II

Lab 28

Hash Tables

Hash Map

Create a C++ class HashMap that maps ints to strings. The class should have the following functions:

// create an empty map
HashMap::HashMap()

// delete any dynamically allocated memory
HashMap::~HashMap()

// insert a key/value pair
// if the key is already in the map, update the key's value
void HashMap::insert(int key, std::string value)

// return a copy of the value associated with a key
// function should assert that key is in the map
std::string HashMap::at(int key) const

// print all of the key/value pairs of a map
std::ostream& operator<<(std::ostream& os, const Map& map)

The hash map should use an array of 10 vectors to store the key / value pairs. Assume that the keys are limited to the range [0, 99].