In this lab, we will look at a simple hashing container. The files are in ~cs253/Labs/Hash.
In main.cc, we have a program that uses
hset (for hash set) template.
hset is much like a
set—it takes a single (for now)
template argument, that is, the type to be contained.
main.cc and run it. Observe that the order of
the output is not the same as the order of the input.
(At least, for the strings. It’s hard to tell for the random numbers.)
hset_iter: an iterator class used by
hset, containing a reference to the
vector, and an integer.
Hasher: a class that only defines functors.
lists, and the
vectoris stuck at size
8. Change that size to be a mandatory second template parameter.
hset. Make it more efficient than just
main, and insert a series of
doubles between 1.0 and 2.0. Observe that it works poorly. Why? How does it even compile?