On this page:
Intro
Recall
Read up on Hashtables
Wrapping a Hashtable as a Table
Evaluation
Submission
6.12

Lab 21: Java Collections: Hashtable

Intro

You’ll work in this lab with ad-hoc partners.

The two of you will work as a team to solve problems. At any time, one of you will be the Head and the other will be the Hands. The Head does the thinking and the Hands does the typing. Hands type only what the Head tells them to, but you’re free to discuss any issues that pop up. You should switch off during the lab to make sure each of you get practice problem solving, dealing with syntax, and getting finger exercises on the keyboard.

You should start this lab with this project skeleton.

Recall

We’ve now seen how to build a real hash table data structure in class. During the last lab, you were asked to evaluate the performance of your hash table and your list implementation of the Table interface.

In this lab, you’ll compare your implementation against Java’s own Hashtable class.

Read up on Hashtables

To start, read the documentation for Java’s Hashtable class. Make some examples and try it out.

Wrapping a Hashtable as a Table

Implement a "wrapper" class that implements your Table interface. That is: implement a class called WrapHashtable that implements Table. The class should have a single Hashtable field and all of the Table methods should be implemented by using the appropriate Hashtable methods on this field.

Be sure to thoroughly test your WrapHashtable class.

Evaluation

Using the code you wrote in Wednesday’s lab, evaluate the performance of this new table implementation. How does it compare to your own hand-rolled hash table?

Submission

Submit a zip file of your work at the end of lab.