The library generic hash function std::hash<T>is used to calculate the hash value for our KEY
type keys. The template header:
template <typename KEY, typename T, typename H = std::hash<KEY>>
indicates there are three type parameters: the key type KEY, the value type T and the function
object type H, which is used to hold the hash function and is assigned a default value, the
std::hash<T> function. To calculate the hash value, simply use
std::size_t key = H()(newkey);
and then mod the value key by the table size.
The hash table will be rehashed dynamically when the load factor reaches 2. This means that the
underlying hash table doubles the size (approximately since we want to keep the table size prime),
and all entries be re-inserted into the table. The hash table does not shrink dynamically when the
entry size reduces.
A public method named tsize()is required so that we can verify your rehash implementation.
Submit unorderedmap.hand unorderedmap.cpp.
You should also fill out the README file and submit it as well. Submit the following files to the
appropriate assignment on Mimir:
unorderedmap.h unorderedmap.cpp README
Do not turn in executables or object code. Programs that produce compile time errors or
warnings will receive a zero mark (even if it might work perfectly on your home computer).
Be sure to provide comments in your program. You must include the information as the section
of comments below:
CS515 Assignment 10
Collaboration Declaration: assistance received from TA, PAC etc.
Some notes on grading:
Programs are graded for correctness (output results and code details), following directions
and using specified features, documentation and style.
To successfully pass the provided sample tests is not an indication of a potential good grade; to
fail one or more of these tests is an indication of a potential bad grade.
You must test thoroughly your program with your own test data/cases to ensure all the
requirements are fulfilled. We will use additional test data/cases other than the sample tests
to grade your program.
Here is a tentative grading scheme.
Unordered Map run 1 (Insert)
Unordered Map run 1 valgrind
Unordered Map run 2 (operator)
Unordered Map run 2 valgrind
Unordered Map run 3 (find)
Unordered Map run 3 valgrind
Unordered Map run 4 (find)
Unordered Map run 5 (erase)
Unordered Map run 5 valgrind
Unordered Map run 6 (erase)
Unordered Map run 7 (iterator++)
Unordered Map run 7 valgrind
Unordered Map run 8 (rehash)
Unordered Map run 8 valgrind