org.apache.commons.math.util
Interface DoubleArray

All Known Implementing Classes:
ExpandableDoubleArray, FixedDoubleArray

public interface DoubleArray

Provides a single interface for dealing with various flavors of double arrays. This arrays framework follows the model of the Collections API by allowing a user to select from a number of array implementations with support for various storage mechanisms such as automatic expansion, contraction, and array "rolling".

Version:
$Revision: 1.7 $ $Date: 2003/11/14 22:22:17 $

Method Summary
 void addElement(double value)
          Adds an element to the end of this expandable array
 double addElementRolling(double value)
          Adds an element and moves the window of elements up one.
 void clear()
          Clear the double array
 double getElement(int index)
          Returns the element at the specified index.
 double[] getElements()
          Returns a double[] of elements
 int getNumElements()
          Returns the number of elements currently in the array.
 void setElement(int index, double value)
          Sets the element at the specified index.
 

Method Detail

getNumElements

public int getNumElements()
Returns the number of elements currently in the array. Please note that this is different from the length of the internal storage array.

Returns:
number of elements

getElement

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 - index to fetch a value from
Returns:
value stored at the specified index

setElement

public void setElement(int index,
                       double value)
Sets the element at the specified index. This method will expand the internal storage array to accomodate the insertion of a value at an index beyond the current capacity.

Parameters:
index - index to store a value in
value - value to store at the specified index

addElement

public void addElement(double value)
Adds an element to the end of this expandable array

Parameters:
value - to be added to end of array

addElementRolling

public double addElementRolling(double value)
Adds an element and moves the window of elements up one. This has the effect of a FIFO. when you "roll" the array an element is removed from the array. The return value of this function is the discarded double.

Parameters:
value - the value to be added to the array
Returns:
the value which has been discarded or "pushed" out of the array by this rolling insert.

getElements

public double[] getElements()
Returns a double[] of elements

Returns:
all elements added to the array

clear

public void clear()
Clear the double array



Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.