DESY ACOP Beans Home

com.cosylab.util
Class ResizableDoubleList

java.lang.Object
  extended by com.cosylab.util.ResizableDoubleList

public class ResizableDoubleList
extends java.lang.Object

This is a gadget for storing values of prmitive double type with java.lang.ArrayList-like functionality and considerably better performance. Woohoo!

Version:
$id$
Author:
Gasper Pajor

Constructor Summary
ResizableDoubleList()
          Constructor for ResizableDoubleList.
ResizableDoubleList(int initialBufferSize)
          Constructor for ResizableDoubleList.
 
Method Summary
 void add(double d)
          Adds a single value to the end of the array.
 void add(double[] da)
          Adds array of doubles to the end of the array.
 void add(double[] da, int index)
          Adds an array of doubles at specified index.
 void add(double d, int index)
          Adds a single value at specified index.
 void displayIndexes()
          This is merely a debug method.
 void displayRelevant()
          This is merely a debug method.
 double get(int index)
          Gets the value at specified index.
 double[] getArray()
          Gets the whole array
 double[] getArray(int index)
          Gets sub-array from specified index onwards.
 double[] getArray(int index, int lenght)
          Gets the sub-array of specified lenght from the specified index
 double[] getBufferArray()
          This method is for testing and debuging purposes only.
static void main(java.lang.String[] args)
          Run test applet.
 void remove(int index, int lenght)
          Removes the specified number of values from (including) specified index onwards.
 void set(int index, double value)
          Sets the value at specified index.
 int size()
          Gets the size of the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResizableDoubleList

public ResizableDoubleList()
Constructor for ResizableDoubleList. Calls this(10) constructor.


ResizableDoubleList

public ResizableDoubleList(int initialBufferSize)
Constructor for ResizableDoubleList.

Parameters:
initialBufferSize - the initial size of buffer array into which the values are stored.
Method Detail

add

public void add(double d)
Adds a single value to the end of the array.

Parameters:
d - value to add

add

public void add(double[] da)
Adds array of doubles to the end of the array.

Parameters:
da - array to add

add

public void add(double d,
                int index)
Adds a single value at specified index. All values that have index equal to or larger than specified index increase their indexes by one.

Parameters:
d - value to add
index - the index at which the value will be inserted

add

public void add(double[] da,
                int index)
Adds an array of doubles at specified index. All values that have index equal to or larger than specified index increase their indexes by the lenght of the added array.

Parameters:
da - array to add
index - the index at which the array will be inserted

remove

public void remove(int index,
                   int lenght)
Removes the specified number of values from (including) specified index onwards.

Parameters:
index - the index of first value to remove
lenght - the number of values to remove

size

public int size()
Gets the size of the array.

Returns:
int the size of the array

getArray

public double[] getArray()
Gets the whole array

Returns:
double[] the array

getArray

public double[] getArray(int index,
                         int lenght)
Gets the sub-array of specified lenght from the specified index

Parameters:
index - the index
lenght - the lenght
Returns:
double[] the sub-array

getArray

public double[] getArray(int index)
Gets sub-array from specified index onwards.

Parameters:
index - the index
Returns:
double[] the sub-array

get

public double get(int index)
Gets the value at specified index.

Parameters:
index - the index
Returns:
double the value at index

set

public void set(int index,
                double value)
Sets the value at specified index.

Parameters:
index - the index
value - the new value

getBufferArray

public double[] getBufferArray()
This method is for testing and debuging purposes only. It returns the buffered array from within which the array or relevant values is stored. There should be no need to call this method unless you want to check the working of this class.

Returns:
double[] the buffer array

main

public static void main(java.lang.String[] args)
Run test applet.

Parameters:
args - command line parameters

displayRelevant

public void displayRelevant()
This is merely a debug method.


displayIndexes

public void displayIndexes()
This is merely a debug method.



Copyright © 2010. All Rights Reserved.