IndexedList ADT

  • Declare an ADT using a Java interface.

We are now ready to declare our first ADT in this course, the IndexedList.

public interface IndexedList {

  void put(int index, int value);

  int get(int index);

  int length();
}

The IndexedList ADT is an abstraction of list, a sequential set of elements to which you can add and access (get) data using an index (a non-negative integer representing the position of data in the sequence).

Notice the method and parameter names are descriptive. You can, for example, anticipate that the get method returns the value stored at the given index. First, however, we must adequately document each method, its parameters, return value, effects, etc. We will do this next.