public class DoubleImmutableList extends AbstractDoubleList implements DoubleList, java.util.RandomAccess, java.lang.Cloneable, java.io.Serializable
Instances of this class are immutable and (contrarily to mutable array-based list implementations) the backing array is not exposed. Instances can be built using a variety of methods, but note that constructors using an array will not make a defensive copy.
This class implements the bulk method getElements() using
high-performance system calls (e.g., System.arraycopy()) instead of
expensive loops.
AbstractDoubleList.DoubleRandomAccessSubList, AbstractDoubleList.DoubleSubList| Constructor and Description |
|---|
DoubleImmutableList(java.util.Collection<? extends java.lang.Double> c)
Creates a new immutable list and fills it with a given collection.
|
DoubleImmutableList(double[] a)
Creates a new immutable list using a given array.
|
DoubleImmutableList(double[] a,
int offset,
int length)
Creates a new immutable list and fills it with the elements of a given array.
|
DoubleImmutableList(DoubleCollection c)
Creates a new immutable list and fills it with a given type-specific collection.
|
DoubleImmutableList(it.unimi.dsi.fastutil.doubles.DoubleIterator i)
Creates a new immutable list and fills it with the elements returned by a type-specific iterator..
|
DoubleImmutableList(DoubleList l)
Creates a new immutable list and fills it with a given type-specific list.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(double k)
Deprecated.
|
boolean |
add(java.lang.Double k)
Deprecated.
|
void |
add(int index,
double k)
Deprecated.
|
void |
add(int index,
java.lang.Double k)
Deprecated.
|
boolean |
addAll(java.util.Collection<? extends java.lang.Double> c)
Deprecated.
|
boolean |
addAll(DoubleCollection c)
Deprecated.
|
boolean |
addAll(DoubleList c)
Deprecated.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Double> c)
Deprecated.
|
boolean |
addAll(int index,
DoubleCollection c)
Deprecated.
|
boolean |
addAll(int index,
DoubleList c)
Deprecated.
|
void |
addElements(int index,
double[] a,
int offset,
int length)
Deprecated.
|
void |
clear()
Deprecated.
|
DoubleImmutableList |
clone() |
int |
compareTo(DoubleImmutableList l)
Compares this immutable list to another immutable list.
|
int |
compareTo(java.util.List<? extends java.lang.Double> l)
Compares this list to another object.
|
boolean |
equals(DoubleImmutableList l)
Compares this type-specific immutable list to another one.
|
boolean |
equals(java.lang.Object o) |
void |
forEach(java.util.function.DoubleConsumer action)
Performs the given action for each element of this type-specific
Iterable
until all elements have been processed or the action throws an
exception. |
double |
getDouble(int index)
Returns the element at the specified position in this list.
|
void |
getElements(int from,
double[] a,
int offset,
int length)
Copies element of this type-specific list into the given array using optimized system calls.
|
int |
indexOf(double k)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
|
boolean |
isEmpty() |
int |
lastIndexOf(double k)
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
|
DoubleListIterator |
listIterator(int index)
Returns a type-specific list iterator on the list starting at a given index.
|
static DoubleImmutableList |
of()
Returns an empty immutable list.
|
static DoubleImmutableList |
of(double... init)
Creates an immutable list using a list of elements.
|
boolean |
rem(double k)
Deprecated.
|
java.lang.Double |
remove(int index)
Deprecated.
|
boolean |
remove(java.lang.Object k)
Deprecated.
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeAll(DoubleCollection c)
Deprecated.
|
double |
removeDouble(int index)
Deprecated.
|
void |
removeElements(int from,
int to)
Deprecated.
|
boolean |
removeIf(java.util.function.DoublePredicate c)
Deprecated.
|
boolean |
removeIf(java.util.function.Predicate<? super java.lang.Double> c)
Deprecated.
|
void |
replaceAll(java.util.function.DoubleUnaryOperator operator)
Deprecated.
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Double> operator)
Deprecated.
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
retainAll(DoubleCollection c)
Deprecated.
|
double |
set(int index,
double k)
Deprecated.
|
java.lang.Double |
set(int index,
java.lang.Double k)
Deprecated.
|
void |
setElements(int index,
double[] a,
int offset,
int length)
Deprecated.
|
int |
size() |
void |
size(int size)
Deprecated.
|
void |
sort(java.util.Comparator<? super java.lang.Double> comparator)
Deprecated.
|
void |
sort(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
Deprecated.
|
it.unimi.dsi.fastutil.doubles.DoubleSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this list.
|
DoubleList |
subList(int from,
int to)
Returns a type-specific view of the portion of this list from the index
from, inclusive, to the index to, exclusive. |
double[] |
toArray(double[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
|
double[] |
toDoubleArray()
Returns a primitive type array containing the items of this collection.
|
static DoubleImmutableList |
toList(java.util.stream.DoubleStream stream)
Collects the result of a primitive
Stream into a new ImmutableList. |
static DoubleImmutableList |
toListWithExpectedSize(java.util.stream.DoubleStream stream,
int expectedSize)
Collects the result of a primitive
Stream into a new ImmutableList, potentially pre-allocated to handle the given size. |
void |
unstableSort(java.util.Comparator<? super java.lang.Double> comparator)
Deprecated.
|
void |
unstableSort(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
Deprecated.
|
addElements, contains, ensureIndex, ensureRestrictedIndex, hashCode, iterator, listIterator, peekDouble, popDouble, push, replaceAll, topDouble, toStringcontains, containsAll, containsAll, forEach, removeIf, toDoubleArrayfinalize, getClass, notify, notifyAll, wait, wait, waitadd, add, add, add, addAll, addAll, addAll, addElements, addElements, contains, get, indexOf, iterator, lastIndexOf, listIterator, of, of, of, remove, remove, removeDouble, removeElements, replaceAll, replaceAll, replaceAll, set, set, setElements, setElements, setElements, size, sort, sort, unstableSort, unstableSortaddAll, addAll, clear, containsAll, hashCode, removeAll, retainAll, toArray, toArrayaddAll, contains, containsAll, doubleIterator, doubleParallelStream, doubleSpliterator, doubleStream, parallelStream, rem, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toDoubleArrayforEach, forEachpeek, pop, push, toppublic DoubleImmutableList(double[] a)
Note that this constructor does not perform a defensive copy.
a - the array that will be used to back this immutable list.public DoubleImmutableList(java.util.Collection<? extends java.lang.Double> c)
c - a collection that will be used to fill the immutable list.public DoubleImmutableList(DoubleCollection c)
c - a type-specific collection that will be used to fill the immutable list.public DoubleImmutableList(DoubleList l)
l - a type-specific list that will be used to fill the immutable list.public DoubleImmutableList(double[] a,
int offset,
int length)
a - an array whose elements will be used to fill the immutable list.offset - the first element to use.length - the number of elements to use.public DoubleImmutableList(it.unimi.dsi.fastutil.doubles.DoubleIterator i)
i - a type-specific iterator whose returned elements will fill the immutable list.public static DoubleImmutableList of()
of in interface DoubleListpublic static DoubleImmutableList of(double... init)
Note that this method does not perform a defensive copy.
of in interface DoubleListinit - a list of elements that will be used to initialize the list.public static DoubleImmutableList toList(java.util.stream.DoubleStream stream)
Stream into a new ImmutableList.
This method performs a terminal operation on the given Stream
public static DoubleImmutableList toListWithExpectedSize(java.util.stream.DoubleStream stream, int expectedSize)
Stream into a new ImmutableList, potentially pre-allocated to handle the given size.
This method performs a terminal operation on the given Stream
public double getDouble(int index)
DoubleListgetDouble in interface DoubleListList.get(int)public int indexOf(double k)
DoubleListindexOf in interface DoubleListindexOf in class AbstractDoubleListList.indexOf(Object)public int lastIndexOf(double k)
DoubleListlastIndexOf in interface DoubleListlastIndexOf in class AbstractDoubleListList.lastIndexOf(Object)public int size()
size in interface java.util.Collection<java.lang.Double>size in interface java.util.List<java.lang.Double>size in class java.util.AbstractCollection<java.lang.Double>public boolean isEmpty()
isEmpty in interface it.unimi.dsi.fastutil.Stack<java.lang.Double>isEmpty in interface java.util.Collection<java.lang.Double>isEmpty in interface java.util.List<java.lang.Double>isEmpty in class java.util.AbstractCollection<java.lang.Double>public void getElements(int from,
double[] a,
int offset,
int length)
getElements in interface DoubleListgetElements in class AbstractDoubleListfrom - the start index (inclusive).a - the destination array.offset - the offset into the destination array where to store the first element copied.length - the number of elements to be copied.public void forEach(java.util.function.DoubleConsumer action)
AbstractDoubleListIterable
until all elements have been processed or the action throws an
exception.forEach in interface DoubleIterableforEach in class AbstractDoubleListaction - the action to be performed for each element.Iterable.forEach(java.util.function.Consumer)public double[] toDoubleArray()
DoubleCollectiontoDoubleArray in interface DoubleCollectiontoDoubleArray in class AbstractDoubleListCollection.toArray()public double[] toArray(double[] a)
DoubleCollectionNote that, contrarily to Collection.toArray(Object[]), this
methods just writes all elements of this collection: no special
value will be added after the last one.
toArray in interface DoubleCollectiontoArray in class AbstractDoubleLista - if this array is big enough, it will be used to store this collection.Collection.toArray(Object[])public DoubleListIterator listIterator(int index)
AbstractDoubleListlistIterator in interface DoubleListlistIterator in interface java.util.List<java.lang.Double>listIterator in class AbstractDoubleListList.listIterator(int)public it.unimi.dsi.fastutil.doubles.DoubleSpliterator spliterator()
DoubleListList spliterators must report at least Spliterator.SIZED and Spliterator.ORDERED.
See List.spliterator() for more documentation on the requirements
of the returned spliterator.
spliterator in interface DoubleCollectionspliterator in interface DoubleIterablespliterator in interface DoubleListspliterator in interface java.lang.Iterable<java.lang.Double>spliterator in interface java.util.Collection<java.lang.Double>spliterator in interface java.util.List<java.lang.Double>public DoubleList subList(int from, int to)
from, inclusive, to the index to, exclusive.subList in interface DoubleListsubList in interface java.util.List<java.lang.Double>subList in class AbstractDoubleListList.subList(int,int)public DoubleImmutableList clone()
clone in class java.lang.Objectpublic boolean equals(DoubleImmutableList l)
l - a type-specific immutable list.public boolean equals(java.lang.Object o)
equals in interface java.util.Collection<java.lang.Double>equals in interface java.util.List<java.lang.Double>equals in class AbstractDoubleListpublic int compareTo(DoubleImmutableList l)
l - an immutable list.public int compareTo(java.util.List<? extends java.lang.Double> l)
AbstractDoubleListList, this method performs a lexicographical comparison; otherwise,
it throws a ClassCastException.compareTo in interface java.lang.Comparable<java.util.List<? extends java.lang.Double>>compareTo in class AbstractDoubleListl - a list.List, a negative integer,
zero, or a positive integer as this list is lexicographically less than, equal
to, or greater than the argument.@Deprecated
public final void add(int index,
double k)
AbstractDoubleListadd in interface DoubleListadd in class AbstractDoubleListList.add(int,Object)@Deprecated public final boolean add(double k)
AbstractDoubleListadd in interface DoubleCollectionadd in interface DoubleListadd in class AbstractDoubleListCollection.add(Object)@Deprecated public final boolean addAll(java.util.Collection<? extends java.lang.Double> c)
AbstractDoubleListaddAll in interface java.util.Collection<java.lang.Double>addAll in interface java.util.List<java.lang.Double>addAll in class AbstractDoubleList@Deprecated
public final boolean addAll(int index,
java.util.Collection<? extends java.lang.Double> c)
AbstractDoubleListaddAll in interface java.util.List<java.lang.Double>addAll in class AbstractDoubleList@Deprecated public final double removeDouble(int index)
AbstractDoubleListremoveDouble in interface DoubleListremoveDouble in class AbstractDoubleListList.remove(int)@Deprecated public final boolean rem(double k)
AbstractDoubleListrem in interface DoubleCollectionrem in class AbstractDoubleListList.remove(Object)@Deprecated public final boolean removeAll(java.util.Collection<?> c)
AbstractDoubleCollectionremoveAll in interface java.util.Collection<java.lang.Double>removeAll in interface java.util.List<java.lang.Double>removeAll in class AbstractDoubleCollection@Deprecated public final boolean retainAll(java.util.Collection<?> c)
AbstractDoubleCollectionretainAll in interface java.util.Collection<java.lang.Double>retainAll in interface java.util.List<java.lang.Double>retainAll in class AbstractDoubleCollection@Deprecated public final boolean removeIf(java.util.function.Predicate<? super java.lang.Double> c)
DoubleCollectionremoveIf in interface DoubleCollectionremoveIf in interface java.util.Collection<java.lang.Double>@Deprecated public final boolean removeIf(java.util.function.DoublePredicate c)
DoubleCollectionremoveIf in interface DoubleCollectionc - a predicate which returns true for elements to be
removed.true if any elements were removed.Collection.removeIf(java.util.function.Predicate)@Deprecated public final void replaceAll(java.util.function.UnaryOperator<java.lang.Double> operator)
DoubleListreplaceAll in interface DoubleListreplaceAll in interface java.util.List<java.lang.Double>@Deprecated public final void replaceAll(java.util.function.DoubleUnaryOperator operator)
DoubleListreplaceAll in interface DoubleListoperator - the operator to apply to each element.List.replaceAll(java.util.function.UnaryOperator<E>)@Deprecated
public final void add(int index,
java.lang.Double k)
DoubleListadd in interface DoubleListadd in interface java.util.List<java.lang.Double>@Deprecated public final boolean add(java.lang.Double k)
AbstractDoubleCollectionadd in interface DoubleCollectionadd in interface DoubleListadd in interface java.util.Collection<java.lang.Double>add in interface java.util.List<java.lang.Double>add in class AbstractDoubleCollection@Deprecated public final java.lang.Double remove(int index)
DoubleListremove in interface DoubleListremove in interface java.util.List<java.lang.Double>@Deprecated public final boolean remove(java.lang.Object k)
AbstractDoubleCollectionremove in interface DoubleCollectionremove in interface DoubleListremove in interface java.util.Collection<java.lang.Double>remove in interface java.util.List<java.lang.Double>remove in class AbstractDoubleCollection@Deprecated
public final java.lang.Double set(int index,
java.lang.Double k)
DoubleListset in interface DoubleListset in interface java.util.List<java.lang.Double>@Deprecated public final boolean addAll(DoubleCollection c)
AbstractDoubleListaddAll in interface DoubleCollectionaddAll in class AbstractDoubleListc - a type-specific collection.true if this collection changed as a result of the call.Collection.addAll(Collection)@Deprecated public final boolean addAll(DoubleList c)
DoubleListaddAll in interface DoubleListList.addAll(Collection)@Deprecated
public final boolean addAll(int index,
DoubleCollection c)
DoubleListaddAll in interface DoubleListaddAll in class AbstractDoubleListList.addAll(int,java.util.Collection)@Deprecated
public final boolean addAll(int index,
DoubleList c)
DoubleListaddAll in interface DoubleListList.addAll(int,Collection)@Deprecated public final boolean removeAll(DoubleCollection c)
DoubleCollectionremoveAll in interface DoubleCollectionremoveAll in class AbstractDoubleCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.removeAll(Collection)@Deprecated public final boolean retainAll(DoubleCollection c)
DoubleCollectionretainAll in interface DoubleCollectionretainAll in class AbstractDoubleCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.retainAll(Collection)@Deprecated
public final double set(int index,
double k)
AbstractDoubleListset in interface DoubleListset in class AbstractDoubleListList.set(int,Object)@Deprecated public final void clear()
AbstractDoubleListclear in interface java.util.Collection<java.lang.Double>clear in interface java.util.List<java.lang.Double>clear in class AbstractDoubleList@Deprecated public final void size(int size)
DoubleListIf the specified size is smaller than the current size, the last elements are
discarded. Otherwise, they are filled with 0/null/false.
size in interface DoubleListsize in class AbstractDoubleListsize - the new size.@Deprecated
public final void removeElements(int from,
int to)
AbstractDoubleListThis is a trivial iterator-based based implementation. It is expected that implementations will override this method with a more optimized version.
removeElements in interface DoubleListremoveElements in class AbstractDoubleListfrom - the start index (inclusive).to - the end index (exclusive).@Deprecated
public final void addElements(int index,
double[] a,
int offset,
int length)
AbstractDoubleListThis is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
addElements in interface DoubleListaddElements in class AbstractDoubleListindex - the index at which to add elements.a - the array containing the elements.offset - the offset of the first element to add.length - the number of elements to add.@Deprecated
public final void setElements(int index,
double[] a,
int offset,
int length)
DoubleList
ListIterator iter = listIterator(index);
int i = 0;
while (i < length) {
iter.next();
iter.set(a[offset + i++]);
}
However, the exact implementation may be more efficient, taking into account
whether random access is faster or not, or at the discretion of subclasses,
abuse internals.setElements in interface DoubleListsetElements in class AbstractDoubleListindex - the index at which to start setting elements.a - the array containing the elementsoffset - the offset of the first element to add.length - the number of elements to add.@Deprecated public final void sort(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
DoubleListPass null to sort using natural ordering.
sort in interface DoubleListList.sort(java.util.Comparator)@Deprecated public final void unstableSort(it.unimi.dsi.fastutil.doubles.DoubleComparator comp)
DoubleListPass null to sort using natural ordering.
This differs from List.sort(java.util.Comparator) in that the results are
not assured to be stable, but may be a bit faster.
Unless a subclass specifies otherwise, the results of the method if the list is concurrently modified during the sort are unspecified.
unstableSort in interface DoubleList@Deprecated public final void sort(java.util.Comparator<? super java.lang.Double> comparator)
DoubleListsort in interface DoubleListsort in interface java.util.List<java.lang.Double>@Deprecated public final void unstableSort(java.util.Comparator<? super java.lang.Double> comparator)
DoubleListunstableSort in interface DoubleList