Top Description Methods
org.apache.commons.math3.util

public Interface DoubleArray

Known Direct Implementers
org.apache.commons.math3.util.ResizableDoubleArray

Provides a standard interface for double arrays. Allows different array implementations to support various storage mechanisms such as automatic expansion, contraction, and array "rolling".

Method Summary

Modifier and TypeMethod and Description
public void
addElement(double
to be added to end of array
value
)

Adds an element to the end of this expandable array

public double

Returns:

the value which has been discarded or "pushed" out of the array by this rolling insert
addElementRolling
(double
the value to be added to the array
value
)

Adds an element to the end of the array and removes the first element in the array.

public void
addElements(double[]
to be added to end of array
values
)

Adds elements to the end of this expandable array

public void
clear()

Clear the double array

public double

Returns:

value stored at the specified index
getElement
(int
index to fetch a value from
index
)

Returns the element at the specified index.

public double[]

Returns:

all elements added to the array
getElements
()

Returns a double[] array containing the elements of this DoubleArray.

public int

Returns:

number of elements
getNumElements
()

Returns the number of elements currently in the array.

public void
setElement(int
index to store a value in
index
,
double
value to store at the specified index
value
)

Sets the element at the specified index.

Method Detail

addElementback to summary
public void addElement(double value)

Adds an element to the end of this expandable array

Parameters
value:double

to be added to end of array

addElementRollingback to summary
public double addElementRolling(double value)

Adds an element to the end of the array and removes the first element in the array. Returns the discarded first element. The effect is similar to a push operation in a FIFO queue.

Example: If the array contains the elements 1, 2, 3, 4 (in that order) and addElementRolling(5) is invoked, the result is an array containing the entries 2, 3, 4, 5 and the value returned is 1.

Parameters
value:double

the value to be added to the array

Returns:double

the value which has been discarded or "pushed" out of the array by this rolling insert

addElementsback to summary
public void addElements(double[] values)

Adds elements to the end of this expandable array

Parameters
values:double[]

to be added to end of array

clearback to summary
public void clear()

Clear the double array

getElementback to summary
public double getElement(int index)

Returns the element at the specified index. Note that if an out of bounds index is supplied a ArrayIndexOutOfBoundsException will be thrown.

Parameters
index:int

index to fetch a value from

Returns:double

value stored at the specified index

Exceptions
ArrayIndexOutOfBoundsException:
if index is less than zero or is greater than getNumElements() - 1.
getElementsback to summary
public double[] getElements()

Returns a double[] array containing the elements of this DoubleArray. If the underlying implementation is array-based, this method should always return a copy, rather than a reference to the underlying array so that changes made to the returned array have no effect on the DoubleArray.

Returns:double[]

all elements added to the array

getNumElementsback to summary
public int getNumElements()

Returns the number of elements currently in the array. Please note that this may be different from the length of the internal storage array.

Returns:int

number of elements

setElementback to summary
public void setElement(int index, double value)

Sets the element at the specified index. If the specified index is greater than getNumElements() - 1, the numElements property is increased to index +1 and additional storage is allocated (if necessary) for the new element and all (uninitialized) elements between the new element and the previous end of the array).

Parameters
index:int

index to store a value in

value:double

value to store at the specified index

Exceptions
ArrayIndexOutOfBoundsException:
if index is less than zero.