Bill Teter
Office:          149 Redcay
Telephone:    2782
Office Hours:  Tuesday, Thursday 9:00-12:00

email:  william.teter@plattsburgh.edu

       

 

Lab 5 Sorted ArrayList

In this lab you will create a generic Sorted ArrayList class that implements the SortedList interface that I have written and is in my repository.  Use svn to get a copy.  You will not use any of the classes from the API.  The objects in a SortedArrayList<AT> will be stored in a field that is an array of Objects.  When you need to compare components of this array you will need to caste the component to AT, the generic type.

You will develop your code in the svn repository.  Include in your repository a file called ReadMe that tells me which methods you have implemented and tested.  As soon as you have developed and tested another method add it to your ReadMe file, and recommit the ReadMe file.

An object of the SortedArrayList<AT extends Comparable<? super AT>> must have its components sorted.  More precisely, if X is a SortedArrayList object, for any 0<=i<j<X.size()  (X.get(i)).compareTo(X.get(j)) < = 0.

Step 1.
    Create the SortedArrayList class and have it implement SortedList interface.  Add all the required method headers and include just enough code so that something is returned if required.  You can always return null for a reference object.  Once the SortedArrayList class compiles you can start adding and testing methods one at a time.

Step 2.
    Create the ReadMe file, add it to the repository, and when a new method has been implemented and tested list it in the ReadMe file and commit the ReadMe file and your new version of SortedArrayList.java

Step 3.
    Study the ArrayList.java class in weiss directory.  Set the initial capacity of the array that holds the items in your SortedArrayList class to 2.  Write the add method so that the array of items is always sorted.  The add() method should be the first one you develop.

By the end of our lab on Wednesday you should have the following methods working:
    add()
    get()
    size()
    isEmpty()
    clear()