IndexedList ADT
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 get
method returns the value stored at the given index
. However, we must properly document each method, its parameters, return value, effects, etc. We will do this next.