| Classic JavaDoc |
Class AbstractSequentialList
java.lang.Object └ java.util.AbstractCollection └ java.util.AbstractList └ java.util.AbstractSequentialList
Direct Known Subclasses:
public abstract class AbstractSequentialList extends AbstractList
This class is the opposite of the AbstractList class in the sense that it implements the "random access" methods (get(int index), set(int index, Object element), set(int index, Object element), add(int index, Object element) and remove(int index)) on top of the list's list iterator, instead of the other way around.
To implement a list the programmer needs only to extend this class and provide implementations for the listIterator and size methods. For an unmodifiable list, the programmer need only implement the list iterator's hasNext, next, hasPrevious, previous and index methods.
For a modifiable list the programmer should additionally implement the list iterator's set method. For a variable-size list the programmer should additionally implement the list iterator's remove and add methods.
The programmer should generally provide a void (no argument) and collection constructor, as per the recommendation in the Collection interface specification.
This class is a member of the Java Collections Framework.
Constructors
protected | AbstractSequentialList () | |
Sole constructor. (For invocation by subclass constructors, typically implicit.) |
Methods
void | add (int index, Object element) | |
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). This implementation first gets a list iterator pointing to the indexed element (with list ... more > |
boolean | addAll (int index, Collection c) | |
Inserts all of the elements in the specified collection into this list at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they ... more > |
| get (int index) | ||
Returns the element at the specified position in this list. This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it gets the element using ListIterator.next and returns it. |
| iterator () | ||
Returns an iterator over the elements in this list (in proper sequence). This implementation merely returns a list iterator over the list. |
abstract ListIterator | listIterator (int index) | |
Returns a list iterator over the elements in this list (in proper sequence). |
| remove (int index) | ||
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it removes the element with Li ... more > |
| set (int index, Object element) | ||
Replaces the element at the specified position in this list with the specified element. This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it gets the current element using ListIterator.next and replaces it with ListIte ... more > |
Inherited methods
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
Community comments
Powered by JavaDocPlus