de.jstacs.utils
Class DoubleList

java.lang.Object
  extended by de.jstacs.utils.DoubleList
All Implemented Interfaces:
Storable, Cloneable

public final class DoubleList
extends Object
implements Storable, Cloneable

A simple list of primitive type double.

Author:
Jens Keilwagen, Jan Grau

Constructor Summary
DoubleList()
          This is the default constructor that creates a DoubleList with initial length 10.
DoubleList(int size)
          This is the default constructor that creates a DoubleList with initial length size.
DoubleList(StringBuffer rep)
          This is the constructor for the interface Storable.
 
Method Summary
 void add(double val)
          Adds the element val at the end of the list.
 void add(double val, int fromIndex, int toIndex)
          Adds the element val from fromIndex to toIndex (exclusive).
 void addAll(DoubleList list2)
          This method adds all elements of DoubleList list2 to the current list.
 void addTo(int start, int end, double summand)
          Adds to all values in the list from index start to end the value summand.
 void clear()
          Removes all elements from the list.
 DoubleList clone()
           
 double get(int index)
          Returns the element with the specified index.
 int length()
          Returns the number of inserted elements.
 double mean(int start, int end)
          This method computes the mean of a part of the list.
 double median(int start, int end)
          This method computes the median of a part of the list.
 double min(int start, int end)
          This method computes the minimum of a part of the list.
 void multiply(int start, int end, double factor)
          Multiplies all values in the list from index start to end with the value factor.
 double sd(int start, int end)
          This method computes the standard deviation of a part of the list.
 double[] toArray()
          This method returns a double array containing all elements of the list.
 double[] toArray(int start, int end)
          This method returns a double array containing all elements of the list between start and end (exclusive).
 String toString()
           
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoubleList

public DoubleList()
This is the default constructor that creates a DoubleList with initial length 10.


DoubleList

public DoubleList(int size)
           throws IllegalArgumentException
This is the default constructor that creates a DoubleList with initial length size.

Parameters:
size - the initial size, has to be positive
Throws:
IllegalArgumentException - if size is less than 1

DoubleList

public DoubleList(StringBuffer rep)
           throws NonParsableException
This is the constructor for the interface Storable. Constructs a DoubleList out of an XML representation.

Parameters:
rep - the XML representation as StringBuffer
Throws:
NonParsableException - if the XML representation could not be parsed
Method Detail

clone

public DoubleList clone()
                 throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

addAll

public void addAll(DoubleList list2)
This method adds all elements of DoubleList list2 to the current list.

Parameters:
list2 - a list of elements to be added

add

public final void add(double val)
Adds the element val at the end of the list.

Parameters:
val - the element that should be inserted

add

public void add(double val,
                int fromIndex,
                int toIndex)
Adds the element val from fromIndex to toIndex (exclusive).

Parameters:
val - the element that should be inserted
fromIndex - the start index (inclusive)
toIndex - the end index (exclusive)

clear

public final void clear()
Removes all elements from the list.


get

public final double get(int index)
Returns the element with the specified index.

Parameters:
index - the specified index of the element to return
Returns:
the corresponding element

length

public final int length()
Returns the number of inserted elements.

Returns:
the number of inserted elements

toArray

public double[] toArray()
This method returns a double array containing all elements of the list.

Returns:
a double array containing all elements of the list

toArray

public double[] toArray(int start,
                        int end)
This method returns a double array containing all elements of the list between start and end (exclusive).

Parameters:
start - the first position to consider
end - the index after the last position to consider
Returns:
a double array containing the elements of the list

multiply

public void multiply(int start,
                     int end,
                     double factor)
Multiplies all values in the list from index start to end with the value factor.

Parameters:
start - the start index (inclusive)
end - the end index (exclusive)
factor - the factor with which the values in the list are multiplied

addTo

public void addTo(int start,
                  int end,
                  double summand)
Adds to all values in the list from index start to end the value summand.

Parameters:
start - the start index (inclusive)
end - the end index (exclusive)
summand - the summand which is added to the values in the list

mean

public double mean(int start,
                   int end)
This method computes the mean of a part of the list. Please note that start has to be smaller than end and end has to be smaller than length().

Parameters:
start - the start index (inclusive)
end - the end index (exclusive)
Returns:
the mean of the part of the list

sd

public double sd(int start,
                 int end)
This method computes the standard deviation of a part of the list. Please note that start has to be smaller than end and end has to be smaller than length().

Parameters:
start - the start index (inclusive)
end - the end index (exclusive)
Returns:
the standard deviation of the part of the list

min

public double min(int start,
                  int end)
This method computes the minimum of a part of the list. Please note that start has to be smaller than end and end has to be smaller than length().

Parameters:
start - the start index (inclusive)
end - the end index (exclusive)
Returns:
the minimum of the part of the list

median

public double median(int start,
                     int end)
This method computes the median of a part of the list. Please note that start has to be smaller than end and end has to be smaller than length().

Parameters:
start - the start index (inclusive)
end - the end index (exclusive)
Returns:
the median of the part of the list

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Returns:
the XML representation

toString

public String toString()
Overrides:
toString in class Object