public class FloatImmutableList extends AbstractFloatList implements FloatList, 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.
AbstractFloatList.FloatRandomAccessSubList, AbstractFloatList.FloatSubList
Constructor and Description |
---|
FloatImmutableList(java.util.Collection<? extends java.lang.Float> c)
Creates a new immutable list and fills it with a given collection.
|
FloatImmutableList(float[] a)
Creates a new immutable list using a given array.
|
FloatImmutableList(float[] a,
int offset,
int length)
Creates a new immutable list and fills it with the elements of a given array.
|
FloatImmutableList(FloatCollection c)
Creates a new immutable list and fills it with a given type-specific collection.
|
FloatImmutableList(FloatIterator i)
Creates a new immutable list and fills it with the elements returned by a type-specific iterator..
|
FloatImmutableList(FloatList l)
Creates a new immutable list and fills it with a given type-specific list.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(float k)
Deprecated.
|
boolean |
add(java.lang.Float k)
Deprecated.
|
void |
add(int index,
float k)
Deprecated.
|
void |
add(int index,
java.lang.Float k)
Deprecated.
|
boolean |
addAll(java.util.Collection<? extends java.lang.Float> c)
Deprecated.
|
boolean |
addAll(FloatCollection c)
Deprecated.
|
boolean |
addAll(FloatList c)
Deprecated.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Float> c)
Deprecated.
|
boolean |
addAll(int index,
FloatCollection c)
Deprecated.
|
boolean |
addAll(int index,
FloatList c)
Deprecated.
|
void |
addElements(int index,
float[] a,
int offset,
int length)
Deprecated.
|
void |
clear()
Deprecated.
|
FloatImmutableList |
clone() |
int |
compareTo(FloatImmutableList l)
Compares this immutable list to another immutable list.
|
int |
compareTo(java.util.List<? extends java.lang.Float> l)
Compares this list to another object.
|
boolean |
equals(FloatImmutableList l)
Compares this type-specific immutable list to another one.
|
boolean |
equals(java.lang.Object o) |
void |
forEach(FloatConsumer 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. |
void |
getElements(int from,
float[] a,
int offset,
int length)
Copies element of this type-specific list into the given array using optimized system calls.
|
float |
getFloat(int index)
Returns the element at the specified position in this list.
|
int |
indexOf(float 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()
Checks whether the stack is empty.
|
int |
lastIndexOf(float 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.
|
FloatListIterator |
listIterator(int index)
Returns a type-specific list iterator on the list starting at a given index.
|
static FloatImmutableList |
of()
Returns an empty immutable list.
|
static FloatImmutableList |
of(float... init)
Creates an immutable list using a list of elements.
|
boolean |
rem(float k)
Deprecated.
|
java.lang.Float |
remove(int index)
Deprecated.
|
boolean |
remove(java.lang.Object k)
Deprecated.
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeAll(FloatCollection c)
Deprecated.
|
void |
removeElements(int from,
int to)
Deprecated.
|
float |
removeFloat(int index)
Deprecated.
|
boolean |
removeIf(FloatPredicate c)
Deprecated.
|
boolean |
removeIf(java.util.function.Predicate<? super java.lang.Float> c)
Deprecated.
|
void |
replaceAll(java.util.function.DoubleUnaryOperator operator)
Deprecated.
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Float> operator)
Deprecated.
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
retainAll(FloatCollection c)
Deprecated.
|
float |
set(int index,
float k)
Deprecated.
|
java.lang.Float |
set(int index,
java.lang.Float k)
Deprecated.
|
void |
setElements(int index,
float[] a,
int offset,
int length)
Deprecated.
|
int |
size() |
void |
size(int size)
Deprecated.
|
void |
sort(java.util.Comparator<? super java.lang.Float> comparator)
Deprecated.
|
void |
sort(FloatComparator comp)
Deprecated.
|
FloatSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this list.
|
FloatList |
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. |
float[] |
toArray(float[] 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.
|
float[] |
toFloatArray()
Returns a primitive type array containing the items of this collection.
|
void |
unstableSort(java.util.Comparator<? super java.lang.Float> comparator)
Deprecated.
|
void |
unstableSort(FloatComparator comp)
Deprecated.
|
addElements, contains, hashCode, iterator, listIterator, peekFloat, popFloat, push, topFloat, toString
contains, containsAll, containsAll, toFloatArray
add, add, add, add, addAll, addAll, addAll, addElements, addElements, contains, get, indexOf, iterator, lastIndexOf, listIterator, of, of, of, remove, remove, removeElements, removeFloat, replaceAll, replaceAll, replaceAll, set, set, setElements, setElements, setElements, size, sort, sort, unstableSort, unstableSort
addAll, addAll, clear, containsAll, hashCode, removeAll, retainAll, toArray, toArray
addAll, contains, containsAll, doubleIterator, doubleParallelStream, doubleSpliterator, doubleStream, parallelStream, rem, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toFloatArray
forEach, forEach
peek, pop, push, top
public FloatImmutableList(float[] a)
Note that this constructor does not perform a defensive copy.
a
- the array that will be used to back this immutable list.public FloatImmutableList(java.util.Collection<? extends java.lang.Float> c)
c
- a collection that will be used to fill the immutable list.public FloatImmutableList(FloatCollection c)
c
- a type-specific collection that will be used to fill the immutable list.public FloatImmutableList(FloatList l)
l
- a type-specific list that will be used to fill the immutable list.public FloatImmutableList(float[] 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 FloatImmutableList(FloatIterator i)
i
- a type-specific iterator whose returned elements will fill the immutable list.public static FloatImmutableList of()
public static FloatImmutableList of(float... init)
Note that this method does not perform a defensive copy.
public float getFloat(int index)
FloatList
public int indexOf(float k)
FloatList
indexOf
in interface FloatList
indexOf
in class AbstractFloatList
List.indexOf(Object)
public int lastIndexOf(float k)
FloatList
lastIndexOf
in interface FloatList
lastIndexOf
in class AbstractFloatList
List.lastIndexOf(Object)
public int size()
size
in interface java.util.Collection<java.lang.Float>
size
in interface java.util.List<java.lang.Float>
size
in class java.util.AbstractCollection<java.lang.Float>
public boolean isEmpty()
Stack
isEmpty
in interface Stack<java.lang.Float>
isEmpty
in interface java.util.Collection<java.lang.Float>
isEmpty
in interface java.util.List<java.lang.Float>
isEmpty
in class java.util.AbstractCollection<java.lang.Float>
public void getElements(int from, float[] a, int offset, int length)
getElements
in interface FloatList
getElements
in class AbstractFloatList
from
- 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(FloatConsumer action)
AbstractFloatList
Iterable
until all elements have been processed or the action throws an
exception.forEach
in interface FloatIterable
forEach
in class AbstractFloatList
action
- the action to be performed for each element.Iterable.forEach(java.util.function.Consumer)
public float[] toFloatArray()
FloatCollection
toFloatArray
in interface FloatCollection
toFloatArray
in class AbstractFloatList
Collection.toArray()
public float[] toArray(float[] a)
FloatCollection
Note 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 FloatCollection
toArray
in class AbstractFloatList
a
- if this array is big enough, it will be used to store this collection.Collection.toArray(Object[])
public FloatListIterator listIterator(int index)
AbstractFloatList
listIterator
in interface FloatList
listIterator
in interface java.util.List<java.lang.Float>
listIterator
in class AbstractFloatList
List.listIterator(int)
public FloatSpliterator spliterator()
FloatList
List 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 FloatCollection
spliterator
in interface FloatIterable
spliterator
in interface FloatList
spliterator
in interface java.lang.Iterable<java.lang.Float>
spliterator
in interface java.util.Collection<java.lang.Float>
spliterator
in interface java.util.List<java.lang.Float>
public FloatList subList(int from, int to)
from
, inclusive, to the index to
, exclusive.subList
in interface FloatList
subList
in interface java.util.List<java.lang.Float>
subList
in class AbstractFloatList
List.subList(int,int)
ImmutableList
due to complications of implementation details.
This may change in a future version (in other words, do not consider the return type of
this method to be stable if making a subclass of ImmutableList
).public FloatImmutableList clone()
clone
in class java.lang.Object
public boolean equals(FloatImmutableList l)
l
- a type-specific immutable list.public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<java.lang.Float>
equals
in interface java.util.List<java.lang.Float>
equals
in class AbstractFloatList
public int compareTo(FloatImmutableList l)
l
- an immutable list.public int compareTo(java.util.List<? extends java.lang.Float> l)
AbstractFloatList
List
, this method performs a lexicographical comparison; otherwise,
it throws a ClassCastException
.compareTo
in interface java.lang.Comparable<java.util.List<? extends java.lang.Float>>
compareTo
in class AbstractFloatList
l
- 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, float k)
AbstractFloatList
add
in interface FloatList
add
in class AbstractFloatList
List.add(int,Object)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean add(float k)
AbstractFloatList
add
in interface FloatCollection
add
in interface FloatList
add
in class AbstractFloatList
Collection.add(Object)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean addAll(java.util.Collection<? extends java.lang.Float> c)
AbstractFloatList
addAll
in interface java.util.Collection<java.lang.Float>
addAll
in interface java.util.List<java.lang.Float>
addAll
in class AbstractFloatList
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean addAll(int index, java.util.Collection<? extends java.lang.Float> c)
AbstractFloatList
addAll
in interface java.util.List<java.lang.Float>
addAll
in class AbstractFloatList
UnsupportedOperationException
as this is an immutable type.@Deprecated public final float removeFloat(int index)
AbstractFloatList
removeFloat
in interface FloatList
removeFloat
in class AbstractFloatList
List.remove(int)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean rem(float k)
AbstractFloatList
rem
in interface FloatCollection
rem
in class AbstractFloatList
List.remove(Object)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean removeAll(java.util.Collection<?> c)
AbstractFloatCollection
removeAll
in interface java.util.Collection<java.lang.Float>
removeAll
in interface java.util.List<java.lang.Float>
removeAll
in class AbstractFloatCollection
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean retainAll(java.util.Collection<?> c)
AbstractFloatCollection
retainAll
in interface java.util.Collection<java.lang.Float>
retainAll
in interface java.util.List<java.lang.Float>
retainAll
in class AbstractFloatCollection
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean removeIf(java.util.function.Predicate<? super java.lang.Float> c)
FloatCollection
removeIf
in interface FloatCollection
removeIf
in interface java.util.Collection<java.lang.Float>
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean removeIf(FloatPredicate c)
FloatCollection
removeIf
in interface FloatCollection
c
- a predicate which returns true
for elements to be
removed.true
if any elements were removed.Collection.removeIf(java.util.function.Predicate)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final void replaceAll(java.util.function.UnaryOperator<java.lang.Float> operator)
FloatList
replaceAll
in interface FloatList
replaceAll
in interface java.util.List<java.lang.Float>
UnsupportedOperationException
as this is an immutable type.@Deprecated public final void replaceAll(java.util.function.DoubleUnaryOperator operator)
FloatList
replaceAll
in interface FloatList
operator
- the operator to apply to each elementList.replaceAll(java.util.function.UnaryOperator<E>)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final void add(int index, java.lang.Float k)
FloatList
@Deprecated public final boolean add(java.lang.Float k)
AbstractFloatCollection
add
in interface FloatCollection
add
in interface FloatList
add
in interface java.util.Collection<java.lang.Float>
add
in interface java.util.List<java.lang.Float>
add
in class AbstractFloatCollection
UnsupportedOperationException
as this is an immutable type.@Deprecated public final java.lang.Float remove(int index)
FloatList
@Deprecated public final boolean remove(java.lang.Object k)
AbstractFloatCollection
remove
in interface FloatCollection
remove
in interface FloatList
remove
in interface java.util.Collection<java.lang.Float>
remove
in interface java.util.List<java.lang.Float>
remove
in class AbstractFloatCollection
UnsupportedOperationException
as this is an immutable type.@Deprecated public final java.lang.Float set(int index, java.lang.Float k)
FloatList
@Deprecated public final boolean addAll(FloatCollection c)
AbstractFloatList
addAll
in interface FloatCollection
addAll
in class AbstractFloatList
c
- a type-specific collection.true
if this collection changed as a result of the call.Collection.addAll(Collection)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean addAll(FloatList c)
FloatList
@Deprecated public final boolean addAll(int index, FloatCollection c)
FloatList
addAll
in interface FloatList
addAll
in class AbstractFloatList
List.addAll(int,java.util.Collection)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean addAll(int index, FloatList c)
FloatList
@Deprecated public final boolean removeAll(FloatCollection c)
FloatCollection
removeAll
in interface FloatCollection
removeAll
in class AbstractFloatCollection
c
- a type-specific collection.true
if this collection changed as a result of the call.Collection.removeAll(Collection)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final boolean retainAll(FloatCollection c)
FloatCollection
retainAll
in interface FloatCollection
retainAll
in class AbstractFloatCollection
c
- a type-specific collection.true
if this collection changed as a result of the call.Collection.retainAll(Collection)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final float set(int index, float k)
AbstractFloatList
set
in interface FloatList
set
in class AbstractFloatList
List.set(int,Object)
UnsupportedOperationException
as this is an immutable type.@Deprecated public final void clear()
AbstractFloatList
clear
in interface java.util.Collection<java.lang.Float>
clear
in interface java.util.List<java.lang.Float>
clear
in class AbstractFloatList
UnsupportedOperationException
as this is an immutable type.@Deprecated public final void size(int size)
FloatList
If 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 FloatList
size
in class AbstractFloatList
size
- the new size.UnsupportedOperationException
as this is an immutable type.@Deprecated public final void removeElements(int from, int to)
AbstractFloatList
This is a trivial iterator-based based implementation. It is expected that implementations will override this method with a more optimized version.
removeElements
in interface FloatList
removeElements
in class AbstractFloatList
from
- the start index (inclusive).to
- the end index (exclusive).UnsupportedOperationException
as this is an immutable type.@Deprecated public final void addElements(int index, float[] a, int offset, int length)
AbstractFloatList
This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
addElements
in interface FloatList
addElements
in class AbstractFloatList
index
- 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.UnsupportedOperationException
as this is an immutable type.@Deprecated public final void setElements(int index, float[] a, int offset, int length)
FloatList
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 FloatList
setElements
in class AbstractFloatList
index
- 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.UnsupportedOperationException
as this is an immutable type.@Deprecated public final void sort(FloatComparator comp)
FloatList
Pass null
to sort using natural ordering.
@Deprecated public final void unstableSort(FloatComparator comp)
FloatList
Pass 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 FloatList
UnsupportedOperationException
as this is an immutable type.@Deprecated public final void sort(java.util.Comparator<? super java.lang.Float> comparator)
FloatList
@Deprecated public final void unstableSort(java.util.Comparator<? super java.lang.Float> comparator)
FloatList
unstableSort
in interface FloatList
UnsupportedOperationException
as this is an immutable type.