This implementation returns a list that subclasses {@code AbstractList}. The subclass stores, in private fields, the offset of the subList within the backing list, the size of the subList (which can change over its lifetime), and the expected {@code modCount} value of the backing list. There are two variantsof the subclass, one of which implements {@code RandomAccess}. If this list implements {@code RandomAccess} the returned list willbe an instance of the subclass that implements {@code RandomAccess}.
The subclass's {@code set(int, E)}, {@code get(int)}, {@code add(int, E)}, {@code remove(int)}, {@code addAll(int,Collection)} and {@code removeRange(int, int)} methods alldelegate to the corresponding methods on the backing abstract list, after bounds-checking the index and adjusting for the offset. The {@code addAll(Collection c)} method merely returns {@code addAll(size,c)}.
The {@code listIterator(int)} method returns a "wrapper object"over a list iterator on the backing list, which is created with the corresponding method on the backing list. The {@code iterator} methodmerely returns {@code listIterator()}, and the {@code size} methodmerely returns the subclass's {@code size} field.
All methods first check to see if the actual {@code modCount} ofthe backing list is equal to its expected value, and throw a {@code ConcurrentModificationException} if it is not. @throws IndexOutOfBoundsException endpoint index value out of range{@code (fromIndex < 0 || toIndex> size)} @throws IllegalArgumentException if the endpoint indices are out of order{@code (fromIndex > toIndex)}
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:
list.subList(from, to).clear();Similar idioms may be constructed for {@link #indexOf(Object)} and{@link #lastIndexOf(Object)}, and all of the algorithms in the {@link 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.) @throws IndexOutOfBoundsException {@inheritDoc} @throws IllegalArgumentException {@inheritDoc}
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:
list.subList(from, to).clear();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.) @param fromIndex low endpoint (inclusive) of the subList @param toIndex high endpoint (exclusive) of the subList @return a view of the specified range within this list @throws IndexOutOfBoundsException for an illegal endpoint index value(fromIndex < 0 || toIndex > size || fromIndex > toIndex)
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 operating on a subList view instead of a whole List. For example, the following idiom removes a range of elements from a List:
list.subList(from, to).clear();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 the List, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) @param fromIndex low endpoint (inclusive) of the subList @param toIndex high endpoint (exclusive) of the subList @return a view of the specified range within this List @throws IndexOutOfBoundsException if an endpoint index value is out of range{@code (fromIndex < 0 || toIndex> size)} @throws IllegalArgumentException if the endpoint indices are out of order{@code (fromIndex > toIndex)}
ByteList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
CharList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
DoubleList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
FloatList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
IntList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
LongList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
ShortList
is backed by me, so that any changes in the returned list are reflected in me, and vice-versa. The returned list supports all of the optional operations that I support. Note that when fromIndex == toIndex
, the returned list is initially empty, and when fromIndex == 0 && toIndex == {@link #size() size()}
the returned list is my "improper" sublist, containing all my elements. The semantics of the returned list become undefined if I am structurally modified in any way other than via the returned list.
@param fromIndex the smallest index (inclusive) in me that appears in the returned list
@param toIndex the largest index (exclusive) in me that appears in the returned list
@return a view of this list from fromIndex (inclusive) to toIndex (exclusive)
@throws IndexOutOfBoundsException if either specified index is out of range
|
|
|
|
|
|
|
|