| Constructor and Description |
|---|
SparseDoubleArray()
Creates an empty sparse array.
|
SparseDoubleArray(int initialCapacity)
Creates an empty sparse array with the given capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all elements from this array.
|
SparseDoubleArray |
clone() |
boolean |
containsElement(double element,
double tolerance)
Checks whether this array contains the given element.
|
boolean |
containsIndex(int index)
Checks whether this array contains the given index.
|
void |
ensureCapacity(int minCapacity)
Increases the capacity of this array, if necessary, to ensure that it can hold at least the given number of elements.
|
void |
forEach(BiConsumer<Integer,Double> action)
Performs the given action for each element in this array until all elements have been processed or the action throws an exception.
|
double |
getOrDefault(int index,
double defaultValue)
Returns the element at the given index in this array.
|
int |
indexOf(double element,
double tolerance)
Returns the index of the first occurrence of the specified element in this array.
|
boolean |
isEmpty()
Checks whether this array is empty.
|
int |
lastIndexOf(double element,
double tolerance)
Returns the index of the last occurrence of the specified element in this array.
|
double |
remove(int index,
double defaultValue)
Removes and returns the element at the given index in this array.
|
void |
set(int index,
double value)
Sets the element at the given index in this array to the given value.
|
void |
setIfAbsent(int index,
double value)
If there is no element in this array at the given index, sets it to the given value.
|
int |
size()
Returns the number of elements in this array.
|
String |
toString() |
void |
trimToSize()
Trims the capacity of this array to its current size.
|
public SparseDoubleArray()
public SparseDoubleArray(int initialCapacity)
public void clear()
public SparseDoubleArray clone()
public boolean containsElement(double element,
double tolerance)
IllegalArgumentException - if tolerance is negativepublic boolean containsIndex(int index)
IllegalArgumentException - if index is negativepublic void ensureCapacity(int minCapacity)
IllegalArgumentException - if minCapacity is negativepublic void forEach(BiConsumer<Integer,Double> action)
IllegalArgumentException - if action is nullpublic double getOrDefault(int index,
double defaultValue)
IllegalArgumentException - if index is negativepublic int indexOf(double element,
double tolerance)
-1 if this array does not contain the element.IllegalArgumentException - if tolerance is negativepublic boolean isEmpty()
public int lastIndexOf(double element,
double tolerance)
-1 if this array does not contain the element.IllegalArgumentException - if tolerance is negativepublic double remove(int index,
double defaultValue)
IllegalArgumentException - if index is negativepublic void set(int index,
double value)
IllegalArgumentException - if index is negativepublic void setIfAbsent(int index,
double value)
IllegalArgumentException - if index is negativepublic int size()
public void trimToSize()