java.lang.Cloneablepublic class SparseDoubleArray
extends java.lang.Object
implements java.lang.Cloneable
| Constructor | Description |
|---|---|
SparseDoubleArray() |
Creates an empty sparse array.
|
SparseDoubleArray(int initialCapacity) |
Creates an empty sparse array with the given capacity.
|
| Modifier and Type | Method | 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(java.util.function.BiConsumer<java.lang.Integer,java.lang.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.
|
java.lang.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()
clone in class java.lang.Objectpublic boolean containsElement(double element,
double tolerance)
java.lang.IllegalArgumentException - if tolerance is negativepublic boolean containsIndex(int index)
java.lang.IllegalArgumentException - if index is negativepublic void ensureCapacity(int minCapacity)
java.lang.IllegalArgumentException - if minCapacity is negativepublic void forEach(java.util.function.BiConsumer<java.lang.Integer,java.lang.Double> action)
java.lang.IllegalArgumentException - if action is nullpublic double getOrDefault(int index,
double defaultValue)
java.lang.IllegalArgumentException - if index is negativepublic int indexOf(double element,
double tolerance)
-1 if this array does not contain the element.java.lang.IllegalArgumentException - if tolerance is negativepublic boolean isEmpty()
public int lastIndexOf(double element,
double tolerance)
-1 if this array does not contain the element.java.lang.IllegalArgumentException - if tolerance is negativepublic double remove(int index,
double defaultValue)
java.lang.IllegalArgumentException - if index is negativepublic void set(int index,
double value)
java.lang.IllegalArgumentException - if index is negativepublic void setIfAbsent(int index,
double value)
java.lang.IllegalArgumentException - if index is negativepublic int size()
public java.lang.String toString()
toString in class java.lang.Objectpublic void trimToSize()