This practice problem was originally no to be turned in, but I'm making it a homework problem to be turned in by Monday, Apr 20. The iterator part is still "optional", but I highly recommend that you test yourself to see if you can do it.
The goal of this exercise is to understand separate chaining. It corresponds to Project 7.1 in the book, pg 525, with a couple of additions.
Find the project code for this at
/homes/tvandrun/Public/cs345/hashing
.
This is the same code base as for the next two projects.
The code contains packages adt
,
impl
, and test
.
Your task is to complete the following methods:
find()
, a helper method that, given a key,
returns the pair (ie, node) containing that key, or
null
if none exists.
(The solution is on pg 321).
put()
, to add a new association to
the map, or overwrite an existing one.
(The solution is on pg 322).
remove()
, which removes a key and its
value from the map, if it exists.
This corresponds to Project 7.1.a in the book.
iterator()
, which returns an
iterator for the keys of this map.
This is a difficult iterator.
Recommended state variables for the iterator itself
are a Pair
variable referring to the
node whose key will be returned by the next call to next()
and an int
variable referring to the bucket
that pair is in.
This corresponds to Project 7.1.b in the book.
To test everything except the iterator, use
SCHMTestNoIterator
.
To test the whole thing, use SCHMTest
Turn in SeparateChainingHashMap.java
to
/cslab/class/cs345/(your userid)/sepchain
Due Monday, Apr 16, 5:00pm
A solution will be available in
/homes/tvandrun/Public/cs345/sepchain-soln
.