Note that this is different from the way in which the variable front is initialized in the lecture
notes.
private int rear. This is the index of the last data item in the ordered list; this is the data item with
the largest value. In the constructor for this class this variable must be initialized to 0. Again, note
that this is different from the way in which variable rear is used in the lecture notes.
private int count. The value of this variable is equal to the number of data items in the list.
•
Circular array list stores objects of the class CellData. These objects are kept sorted in the array
according to their integer value attributes. An example of the array list storing 3 CellData objects in
order of their integer values is shown in the next page.
This class needs to provide the following public methods.
•
public OrderedCircularArray(). Initializes the instance variables as specified above. Array list
must initially have length 5.
Note that when initializing array list as list = new CellData<T>[5]; the compiler will issue an
error message because type T is not known at compilation time. To solve the problem use casting
(create an array of type CellData[] and then cast it to the type that you need).
•
public void insert (T id, int value). Adds a new CellData object storing the given id and value to
the ordered list. You must ensure that after adding this new CellData object the list remains
sorted. Note that the value of front must not change when adding a new CellData object into
the list.