public class PrimitiveDoubleArrayList
extends java.lang.Object
implements java.lang.Iterable<java.lang.Double>
ArrayList
.
The size, isEmpty, get, and iterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation.
Constructor and Description |
---|
PrimitiveDoubleArrayList()
Creates a new array list with space for 16 initial values.
|
PrimitiveDoubleArrayList(int initialSize)
Creates a new array list with a given size.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double value)
Adds a value to the end of this list.
|
void |
clear()
Removes all elements from this list.
|
void |
forEach(java.util.function.Consumer<? super java.lang.Double> action) |
double |
get(int index)
Gets the value at the given index.
|
boolean |
isEmpty()
Checks if this list contains any elements.
|
java.util.Iterator<java.lang.Double> |
iterator() |
int |
size()
Gets the number of elements in this list.
|
java.util.stream.DoubleStream |
stream()
Creates a stream of all the elements in this list.
|
double[] |
toArray()
Creates a new primitive double array containing all the values in this list.
|
void |
trimToSize()
Removes excess entries from the backing array.
|
public PrimitiveDoubleArrayList()
public PrimitiveDoubleArrayList(int initialSize)
initialSize
- the initial number of values the list should contain before needing to be resizedpublic void add(double value)
value
- the value to addpublic double get(int index)
index
- the index to get the value atjava.lang.IndexOutOfBoundsException
- if index is negative or greater than the upper indexpublic void trimToSize()
public int size()
public boolean isEmpty()
public void clear()
public java.util.stream.DoubleStream stream()
public java.util.Iterator<java.lang.Double> iterator()
iterator
in interface java.lang.Iterable<java.lang.Double>
public void forEach(java.util.function.Consumer<? super java.lang.Double> action)
forEach
in interface java.lang.Iterable<java.lang.Double>
public double[] toArray()