This class does not implement java.. If the delegate supports random
access, the ForwardingList subclass should implement the RandomAccess interface.
Warning
The methods of ForwardingList forward indiscriminately to the
methods of the delegate. For example, overriding add alone will not change the
behavior of addAll, which can lead to unexpected behavior. In this case, you should
override addAll as well, either providing your own implementation, or delegating to the
provided standardAddAll method.
default method warning: This class does not forward calls to default methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingList.
The standard methods and any collection views they return are not guaranteed to be
thread-safe, even when all of the methods that they depend on are thread-safe.
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(int
index at which the specified element is to be inserted index, E element to be inserted element)Implements java. |
| 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 elements)Implements java. |
| protected abstract List | delegate()
Implements abstract com. |
| public boolean | equals(Object
the object to be compared for equality with this list object)Overrides java. Implements java. |
| public E | get(int
index of the element to return index)Implements java. |
| public int | hashCode()
Overrides java. Implements java. |
| public int | indexOf(Object
element to search for element)Implements java. |
| public int | lastIndexOf(Object
element to search for element)Implements java. |
| public ListIterator | listIterator()
Implements java. |
| public ListIterator | listIterator(int
index of the first element to be returned from the
list iterator (by a call to index)next)Implements java. |
| public E | remove(int
the index of the element to be removed index)Implements java. |
| public E | set(int
index of the element to replace index, E element to be stored at the specified position element)Implements java. |
| protected boolean | standardAdd(E element)
A sensible default implementation of |
| protected boolean | standardAddAll(int index, Iterable<? extends E> elements)
A sensible default implementation of |
| protected boolean | |
| protected int | |
| protected int | standardIndexOf(Object element)
A sensible default implementation of |
| protected Iterator | |
| protected int | standardLastIndexOf(Object element)
A sensible default implementation of |
| protected ListIterator | standardListIterator()
A sensible default implementation of |
| protected ListIterator | standardListIterator(int start)
A sensible default implementation of |
| protected List | |
| public List | subList(int
low endpoint (inclusive) of the subList fromIndex, int high endpoint (exclusive) of the subList toIndex)Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| ForwardingList | back to summary |
|---|---|
| protected ForwardingList() Constructor for use by subclasses. | |
| add | back to summary |
|---|---|
| public void add(int index, E element) Implements java. Doc from java. Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(int index, Collection<? extends E> elements) Implements java. Doc from java. Inserts all of the elements in the specified collection into this list at the specified position (optional operation). 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 this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
| |
| delegate | back to summary |
|---|---|
| protected abstract List Implements abstract com. Doc from com. Returns the backing delegate instance that methods are forwarded to. Abstract subclasses
generally override this method with an abstract method that has a more specific return type,
such as
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| get | back to summary |
|---|---|
| public E get(int index) Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two lists,
list1 and list2, as required by the general
contract of Object#hashCode.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(Object element) Implements java. Doc from 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.
More formally, returns the lowest index | |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(Object element) Implements java. Doc from 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.
More formally, returns the highest index | |
| listIterator | back to summary |
|---|---|
| public ListIterator Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper sequence).
| |
| listIterator | back to summary |
|---|---|
| public ListIterator Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
The specified index indicates the first element that would be
returned by an initial call to
| |
| remove | back to summary |
|---|---|
| public E remove(int index) Implements java. Doc from java. Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
| |
| set | back to summary |
|---|---|
| public E set(int index, E element) Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| standardAdd | back to summary |
|---|---|
| protected boolean standardAdd(E element) A sensible default implementation of
| |
| standardAddAll | back to summary |
|---|---|
| protected boolean standardAddAll(int index, Iterable<? extends E> elements) A sensible default implementation of
| |
| standardEquals | back to summary |
|---|---|
| protected boolean standardEquals(Object object) A sensible definition of
| |
| standardHashCode | back to summary |
|---|---|
| protected int standardHashCode() A sensible definition of
| |
| standardIndexOf | back to summary |
|---|---|
| protected int standardIndexOf(Object element) A sensible default implementation of
| |
| standardIterator | back to summary |
|---|---|
| protected Iterator A sensible default implementation of
| |
| standardLastIndexOf | back to summary |
|---|---|
| protected int standardLastIndexOf(Object element) A sensible default implementation of
| |
| standardListIterator | back to summary |
|---|---|
| protected ListIterator A sensible default implementation of
| |
| standardListIterator | back to summary |
|---|---|
| protected ListIterator A sensible default implementation of
| |
| standardSubList | back to summary |
|---|---|
| protected List A sensible default implementation of
| |
| subList | back to summary |
|---|---|
| public List Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) | |