List
interface to minimize the effort required to implement this interface
backed by a "random access" data store (such as an array). For sequential
access data (such as a linked list), AbstractSequentialList
should
be used in preference to this class.
To implement an unmodifiable list, the programmer needs only to extend
this class and provide implementations for the get(int)
and
size()
methods.
To implement a modifiable list, the programmer must additionally
override the set(int, E)
method (which otherwise
throws an UnsupportedOperationException
). If the list is
variable-size the programmer must additionally override the
add(int, E)
and remove(int)
methods.
The programmer should generally provide a void (no argument) and collection
constructor, as per the recommendation in the Collection
interface
specification.
Unlike the other abstract collection implementations, the programmer does
not have to provide an iterator implementation; the iterator and
list iterator are implemented by this class, on top of the "random access"
methods:
get(int)
,
set(int, E)
,
add(int, E)
and
remove(int)
.
The documentation for each non-abstract method in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation.
This class is a member of the Java Collections Framework.
Modifier and Type | Class and Description |
---|---|
private class | |
private class | |
pack-priv static class | AbstractList.
An index-based split-by-two, lazily initialized Spliterator covering
a List that access elements via |
private static class | |
private static class |
Modifier and Type | Field and Description |
---|---|
protected transient int | modCount
The number of times this list has been structurally modified. |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
public boolean | add(E
element to be appended to this list e)Overrides java. Implements java. Appends the specified element to the end of this list (optional operation). |
public void | add(int
index at which the specified element is to be inserted index, E element to be inserted element)Implements java. Inserts the specified element at the specified position in this list (optional operation). |
public boolean | addAll(int
index at which to insert the first element from the
specified collection index, Collection<? extends E> collection containing elements to be added to this list c)Implements java. Inserts all of the elements in the specified collection into this list at the specified position (optional operation). |
public void | clear()
Overrides java. Implements java. Removes all of the elements from this list (optional operation). |
public boolean | Returns: true if the specified object is equal to this listthe object to be compared for equality with this list o)Overrides java. Implements java. Compares the specified object with this list for equality. |
public abstract E | get(int
index of the element to return index)Redeclares java. Returns the element at the specified position in this list. |
public int | Returns: the hash code value for this listOverrides java. Implements java. Returns the hash code value for this list. |
public int | indexOf(Object
element to search for o)Implements java. Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. |
public Iterator | Returns: an iterator over the elements in this list in proper sequenceImplements abstract java. Implements java. Returns an iterator over the elements in this list in proper sequence. |
public int | lastIndexOf(Object
element to search for o)Implements java. Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. |
public ListIterator | listIterator()
Implements java. Returns a list iterator over the elements in this list (in proper sequence). |
public ListIterator | listIterator(final int
index of the first element to be returned from the
list iterator (by a call to index)next )Implements java. Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. |
private String | |
private void | |
public E | remove(int
the index of the element to be removed index)Implements java. Removes the element at the specified position in this list (optional operation). |
protected void | removeRange(int
index of first element to be removed fromIndex, int index after last element to be removed toIndex)Removes from this list all of the elements whose index is between
|
public E | set(int
index of the element to replace index, E element to be stored at the specified position element)Implements java. Replaces the element at the specified position in this list with the specified element (optional operation). |
public List | subList(int
low endpoint (inclusive) of the subList fromIndex, int high endpoint (exclusive) of the subList toIndex)Implements java. Returns a view of the portion of this list between the specified
|
pack-priv static void |