// CSE 143, Autumn 2013 // This class captures common code shared by both the ArrayList and LinkedList. // An abstract class is a good way to provide a partially implemented class, or // a partial implementation of an interface. Notice that the header of this // class claims to implement the List interface, but the file doesn't write // all of the methods. // // Java allows this file to compile because it knows that the abstract class // must be extended to complete it. If a subclass of AbstractList doesn't // implement all the rest of the List interface's methods, that subclass will // not compile. public abstract class AbstractList implements List { // post: the list will be one longer and the value will // be added to the end public void add(E value) { add(size(), value); } // Returns true if the given value is found in this list. public boolean contains(E value) { return indexOf(value) >= 0; } // post: returns true if list is empty, false otherwise public boolean isEmpty() { return size() == 0; } }