public class UnmodifiableListShortArrayWrapper extends AbstractBasicUnmodifiableList<java.lang.Short>
This is cheaper than java.util.Arrays.asList()
and allows
for sub arrays to be accessed.
Constructor and Description |
---|
UnmodifiableListShortArrayWrapper(short[] array)
Constructor.
|
UnmodifiableListShortArrayWrapper(short[] array,
int length)
Constructor.
|
UnmodifiableListShortArrayWrapper(short[] array,
int start,
int length)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element.
|
boolean |
containsAll(java.util.Collection c)
Returns true if this list contains all of the elements of the
specified collection.
|
java.lang.Short |
get(int index)
Returns the element at the specified position in this list.
|
int |
indexOf(java.lang.Object o)
Returns the index in this list of the first occurrence of the specified
element, or -1 if this list does not contain this element.
|
boolean |
isEmpty()
Returns true if this list contains no elements.
|
java.util.Iterator<java.lang.Short> |
iterator()
Returns an iterator over the elements in this list in proper sequence.
|
int |
lastIndexOf(java.lang.Object o)
Returns the index in this list of the last occurrence of the specified
element, or -1 if this list does not contain this element.
|
java.util.ListIterator<java.lang.Short> |
listIterator()
Returns a list iterator of the elements in this list (in proper
sequence).
|
java.util.ListIterator<java.lang.Short> |
listIterator(int index)
Returns a list iterator of the elements in this list (in proper
sequence), starting at the specified position in this list.
|
int |
size()
Returns the number of elements in this list.
|
java.util.List<java.lang.Short> |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this list between the specified
fromIndex, inclusive, and toIndex, exclusive.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in proper
sequence.
|
<S> S[] |
toArray(S[] a)
Returns an array containing all of the elements in this list in proper
sequence; the runtime type of the returned array is that of the
specified array.
|
add, add, addAll, addAll, clear, remove, remove, removeAll, retainAll, set
public UnmodifiableListShortArrayWrapper(@NotNull short[] array, int start, int length)
array
- array to wrapstart
- start index to uselength
- length to usepublic UnmodifiableListShortArrayWrapper(@NotNull short[] array)
array
- array to wrappublic UnmodifiableListShortArrayWrapper(@NotNull short[] array, int length)
array
- array to wraplength
- length to usepublic int size()
public boolean isEmpty()
@NotNull public java.lang.Object[] toArray()
Arrays.asList(Object[])
public java.lang.Short get(int index)
index
- index of element to return.java.lang.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public int indexOf(java.lang.Object o)
o
- element to search for.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public int lastIndexOf(java.lang.Object o)
o
- element to search for.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public boolean contains(java.lang.Object o)
o
- element whose presence in this list is to be tested.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public boolean containsAll(@NotNull java.util.Collection c)
c
- collection to be checked for containment in this list.java.lang.ClassCastException
- if the types of one or more elements
in the specified collection are incompatible with this
list (optional).java.lang.NullPointerException
- if the specified collection contains one
or more null elements and this list does not support null
elements (optional).
or if the specified collection is
null.contains(Object)
@NotNull public java.util.Iterator<java.lang.Short> iterator()
@NotNull public java.util.List<java.lang.Short> subList(int fromIndex, int 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 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.)
fromIndex
- low endpoint (inclusive) of the subList.toIndex
- high endpoint (exclusive) of the subList.java.lang.IndexOutOfBoundsException
- for an illegal endpoint index value
(fromIndex < 0 || toIndex > size || fromIndex > toIndex).@NotNull public java.util.ListIterator<java.lang.Short> listIterator()
@NotNull public java.util.ListIterator<java.lang.Short> listIterator(int index)
index
- index of first element to be returned from the
list iterator (by a call to the next method).java.lang.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index > size()).@NotNull public <S> S[] toArray(@NotNull S[] a)
a
- the array into which the elements of this list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.java.lang.ArrayStoreException
- if the runtime type of the specified array
is not a supertype of the runtime type of every element in
this list.java.lang.NullPointerException
- if the specified array is null.