CPSC170A
Fundamentals of Computer Science II

Lab 26

Binary Search

Sorted Map

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

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

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

// insert a key/value pair
// if the key is already in the map, update the key's value
void SortedMap::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 SortedMap::at(int key) const

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

All of the key / value pairs stored in the map should be stored in sorted order according the keys. The at member function should use binary search to find the requested value quickly.