CSCI 151 Lab 4: Extensible arrays and dictionaries


This lab will:

We will start by improving our GenericExtensibleArray class, and then use our improved arrays to create a better (though not more efficient) Dictionary implementation.



Part 1: extending ExtensibleArray

Your first assignment is to add more useful methods to ExtensibleArray. Similar methods already exist in ArrayList, and it is important for you to explore how these methods are implemented. In particular, you should add each of the following methods:

Part 2: Equality for Associations

In order to effectively look up an Association in a Dictionary, we will want to be able to compare two Associations, so we will also implement equals for them. However, we are going to do something a bit strange and just compare their keys, not their values. If we were just implementing a generic class for pairs, this would be the wrong thing to do. However, Associations are not just generic pairs: we are going to use them to store key-value associations, to implement things like dictionaries. In a key-value association, we always look things up by key, so it makes sense to only compare Associations by key.

Part 3: A better dictionary

Finally, we will use the improved ExtensibleArray and Association classes to simplify the implementation of Dictionary.

What to Hand In

You should turn in