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
the hset
(for hash set) template.
An hset
is much like a set—it takes a single (for now)
template argument, that is, the type to be contained.
Compile 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.)
                
Look at hset.h, hset_iter.h, and hasher.h, and understand the following:                 
hset
: a vector
of list
s.
hset_iter
: an iterator class used by hset
,
containing a reference to the vector
, and an integer.
Hasher
: a class that only defines functors.
hset
is a vector
of list
s, and the vector
is stuck at size 8
. Change that size to be a mandatory
second template parameter.
empty()
to hset
.
Make it more efficient than just size()==0
.
main
, and insert a series of double
s
between 1.0 and 2.0. Observe that it works poorly. Why?
How does it even compile?
Hasher
to hash double
s.
hset_iter
is horrible.
hset_iter::operator*
?
User: Guest