Class AbstractSequentialList<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>
Direct Known Subclasses:
LinkedList

public abstract class AbstractSequentialList<E> extends AbstractList<E>
AbstractSequentialList is an abstract implementation of the List interface. This implementation does not support adding. A subclass must implement the abstract method listIterator().
Since:
1.2
  • Field Summary

    Fields inherited from class AbstractList

    modCount
    Modifier and Type
    Field
    Description
    protected int
    A counter for changes to the list.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a new instance of this AbstractSequentialList.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int location, E object)
    Inserts the specified object into this List at the specified location.
    boolean
    addAll(int location, Collection<? extends E> collection)
    Inserts the objects in the specified Collection at the specified location in this List.
    get(int location)
    Returns the element at the specified location in this list.
    Returns an iterator on the elements of this list.
    abstract ListIterator<E>
    listIterator(int location)
    Returns a list iterator on the elements of this list.
    remove(int location)
    Removes the object at the specified location from this list.
    set(int location, E object)
    Replaces the element at the specified location in this list with the specified object.

    Methods inherited from class AbstractList

    add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList, toArray, toArray
    Modifier and Type
    Method
    Description
    boolean
    add(E object)
    Adds the specified object at the end of this List.
    void
    Removes all elements from this list, leaving it empty.
    boolean
    equals(Object object)
    Compares the specified object to this list and return true if they are equal.
    int
    Returns the hash code of this list.
    int
    indexOf(Object object)
    Searches this list for the specified object and returns the index of the first occurrence.
    int
    Searches this list for the specified object and returns the index of the last occurrence.
    Returns a ListIterator on the elements of this list.
    protected void
    removeRange(int start, int end)
    Removes the objects in the specified range from the start to the end index minus one.
    subList(int start, int end)
    Returns a part of consecutive elements of this list as a view.
    Returns a new array containing all elements contained in this ArrayList.
    <T> T[]
    toArray(T[] contents)
    Returns an array containing all elements contained in this ArrayList.

    Methods inherited from class AbstractCollection

    addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toString
    Modifier and Type
    Method
    Description
    boolean
    addAll(Collection<? extends E> collection)
    Attempts to add all of the objects contained in collection to the contents of this Collection (optional).
    boolean
    contains(Object object)
    Tests whether this Collection contains the specified object.
    boolean
    containsAll(Collection<?> collection)
    Tests whether this Collection contains all objects contained in the specified Collection.
    boolean
    Returns if this Collection contains no elements.
    boolean
    remove(Object object)
    Removes one instance of the specified object from this Collection if one is contained (optional).
    boolean
    removeAll(Collection<?> collection)
    Removes all occurrences in this Collection of each object in the specified Collection (optional).
    boolean
    retainAll(Collection<?> collection)
    Removes all objects from this Collection that are not also found in the Collection passed (optional).
    abstract int
    Returns a count of how many objects this Collection contains.
    Returns the string representation of this Collection.

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    final Class
    Returns the runtime class of an object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

    Methods inherited from interface List

    addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size
    Modifier and Type
    Method
    Description
    boolean
    addAll(Collection<? extends E> collection)
    Adds the objects in the specified collection to the end of this List.
    boolean
    contains(Object object)
    Tests whether this List contains the specified object.
    boolean
    containsAll(Collection<?> collection)
    Tests whether this List contains all objects contained in the specified collection.
    boolean
    Returns whether this List contains no elements.
    boolean
    remove(Object object)
    Removes the first occurrence of the specified object from this List.
    boolean
    removeAll(Collection<?> collection)
    Removes all occurrences in this List of each object in the specified collection.
    boolean
    retainAll(Collection<?> collection)
    Removes all objects from this List that are not contained in the specified collection.
    int
    Returns the number of elements in this List.
  • Constructor Details

    • AbstractSequentialList

      protected AbstractSequentialList()
      Constructs a new instance of this AbstractSequentialList.
  • Method Details

    • add

      public void add(int location, E object)
      Description copied from class: AbstractList
      Inserts the specified object into this List at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this List, the object is added at the end.

      Concrete implementations that would like to support the add functionality must override this method.

      Specified by:
      add in interface List<E>
      Overrides:
      add in class AbstractList<E>
      Parameters:
      location - the index at which to insert.
      object - the object to add.
    • addAll

      public boolean addAll(int location, Collection<? extends E> collection)
      Description copied from class: AbstractList
      Inserts the objects in the specified Collection at the specified location in this List. The objects are added in the order they are returned from the collection's iterator.
      Specified by:
      addAll in interface List<E>
      Overrides:
      addAll in class AbstractList<E>
      Parameters:
      location - the index at which to insert.
      collection - the Collection of objects
      Returns:
      true if this List is modified, false otherwise.
    • get

      public E get(int location)
      Description copied from class: AbstractList
      Returns the element at the specified location in this list.
      Specified by:
      get in interface List<E>
      Specified by:
      get in class AbstractList<E>
      Parameters:
      location - the index of the element to return.
      Returns:
      the element at the specified index.
    • iterator

      public Iterator<E> iterator()
      Description copied from class: AbstractList
      Returns an iterator on the elements of this list. The elements are iterated in the same order as they occur in the list.
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface List<E>
      Overrides:
      iterator in class AbstractList<E>
      Returns:
      an iterator on the elements of this list.
      See Also:
    • listIterator

      public abstract ListIterator<E> listIterator(int location)
      Description copied from class: AbstractList
      Returns a list iterator on the elements of this list. The elements are iterated in the same order as they occur in the list. The iteration starts at the specified location.
      Specified by:
      listIterator in interface List<E>
      Overrides:
      listIterator in class AbstractList<E>
      Parameters:
      location - the index at which to start the iteration.
      Returns:
      a ListIterator on the elements of this list.
      See Also:
    • remove

      public E remove(int location)
      Description copied from class: AbstractList
      Removes the object at the specified location from this list.
      Specified by:
      remove in interface List<E>
      Overrides:
      remove in class AbstractList<E>
      Parameters:
      location - the index of the object to remove.
      Returns:
      the removed object.
    • set

      public E set(int location, E object)
      Description copied from class: AbstractList
      Replaces the element at the specified location in this list with the specified object.
      Specified by:
      set in interface List<E>
      Overrides:
      set in class AbstractList<E>
      Parameters:
      location - the index at which to put the specified object.
      object - the object to add.
      Returns:
      the previous element at the index.