visad.util
Class FloatTupleArrayImpl

java.lang.Object
  extended by visad.util.FloatTupleArrayImpl
All Implemented Interfaces:
FloatTupleArray

public class FloatTupleArrayImpl
extends Object
implements FloatTupleArray

Growable array of float tuples.


Nested Class Summary
 
Nested classes/interfaces inherited from interface visad.util.FloatTupleArray
FloatTupleArray.Factory
 
Field Summary
static float DEF_GROW_FACTOR
          Factor by which the arrays are grown when they run out of space.
protected  float[][] elements
           
 
Constructor Summary
FloatTupleArrayImpl(int dim, int initialSize)
           
FloatTupleArrayImpl(int dim, int initialSize, float growFactor)
          Construct an instance of initialSize.
 
Method Summary
 void add(float[][] values)
          Add values.
 void add(float[][] values, int start, int num)
          Add values.
 int dim()
          Get the dimension of the tuple.
 float[][] elements()
          Reference to the backing data array.
 float[] get(int idx)
          Get a tuple.
 float get(int i, int j)
          Get a value.
protected  void grow()
          Grow the internal arrays.
 void set(int i, int j, float val)
          Set a value.
 int size()
          Get the size of the valid data.
 float[][] toArray()
          Get contained data as array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_GROW_FACTOR

public static final float DEF_GROW_FACTOR
Factor by which the arrays are grown when they run out of space.

See Also:
Constant Field Values

elements

protected float[][] elements
Constructor Detail

FloatTupleArrayImpl

public FloatTupleArrayImpl(int dim,
                           int initialSize)

FloatTupleArrayImpl

public FloatTupleArrayImpl(int dim,
                           int initialSize,
                           float growFactor)
Construct an instance of initialSize.

Parameters:
dim - The tuple dimension.
initialSize - The initial size of the internal array.
growFactor - Factor to grow by when resizing is necessary.
Method Detail

grow

protected void grow()
Grow the internal arrays. System.arraycopy is used for array expansion.


add

public void add(float[][] values,
                int start,
                int num)
Add values. If there is not enough space for the number of values to be added the array is continually grown until there is room.

Specified by:
add in interface FloatTupleArray
Parameters:
values - Source array.
start - index in the source array to start at
num - number of values to add.

elements

public float[][] elements()
Reference to the backing data array. Any changes made to this array will be reflected in the actual data.

Specified by:
elements in interface FloatTupleArray
Returns:
This may return a reference or copy depending on the implementation.

add

public void add(float[][] values)
Add values. If there is not enough space for the number of values to be added the array is continually grown until there is room.

Specified by:
add in interface FloatTupleArray
Parameters:
values - Source array.

set

public void set(int i,
                int j,
                float val)
Set a value.

Specified by:
set in interface FloatTupleArray
Parameters:
i - dimension index of the values to set
j - tuple index of the value to set
val - the value

get

public float[] get(int idx)
Get a tuple.

Parameters:
idx - The index of the tuple
Returns:
an array of the tuple values at the provided index.

get

public float get(int i,
                 int j)
Get a value.

Specified by:
get in interface FloatTupleArray
Parameters:
i - dimension index
j - tuple index.
Returns:
The value for tuple i at tuple index j.

toArray

public float[][] toArray()
Get contained data as array. The size of the array is exactly the size of the data.

NOTE: This is an expensive operation.

Specified by:
toArray in interface FloatTupleArray
Returns:
A copy of the array data.

size

public int size()
Get the size of the valid data.

Specified by:
size in interface FloatTupleArray
Returns:
size of array

dim

public int dim()
Get the dimension of the tuple.

Specified by:
dim in interface FloatTupleArray
Returns:
The array tuple dimension