public class UnmodifiableListDoubleArrayWrapper extends AbstractBasicUnmodifiableList<java.lang.Double>
This is cheaper than java.util.Arrays.asList()
and allows
for sub arrays to be accessed.
Constructor and Description |
---|
UnmodifiableListDoubleArrayWrapper(double[] array)
Constructor.
|
UnmodifiableListDoubleArrayWrapper(double[] array,
int length)
Constructor.
|
UnmodifiableListDoubleArrayWrapper(double[] 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.Double |
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.Double> |
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.Double> |
listIterator()
Returns a list iterator of the elements in this list (in proper
sequence).
|
java.util.ListIterator<java.lang.Double> |
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.Double> |
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 UnmodifiableListDoubleArrayWrapper(@NotNull double[] array, int start, int length)
array
- array to wrapstart
- start index to uselength
- length to usepublic UnmodifiableListDoubleArrayWrapper(@NotNull double[] array)
array
- array to wrappublic UnmodifiableListDoubleArrayWrapper(@NotNull double[] 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.Double 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.Double> iterator()
@NotNull public java.util.List<java.lang.Double> 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.Double> listIterator()
@NotNull public java.util.ListIterator<java.lang.Double> 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.