net.esper.collection
Class SortedDoubleVector

java.lang.Object
  extended by net.esper.collection.SortedDoubleVector

public class SortedDoubleVector
extends Object

Sorted, reference-counting set based on a TreeMap implementation that stores keys and a reference counter for each unique key value. Each time the same key is added, the reference counter increases. Each time a key is removed, the reference counter decreases.


Constructor Summary
SortedDoubleVector()
          Constructor.
 
Method Summary
 void add(double value)
          Add a value to the collection.
protected  int findInsertIndex(double value)
          Returns the index into which to insert to.
 double getValue(int index)
          Returns the value at a given index.
protected  ArrayList<Double> getValues()
          Returns underlying ArrayList, for testing purposes only.
 void remove(double value)
          Remove a value from the collection.
 int size()
          Returns the number of items in the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedDoubleVector

public SortedDoubleVector()
Constructor.

Method Detail

size

public int size()
Returns the number of items in the collection.

Returns:
size

getValue

public double getValue(int index)
Returns the value at a given index.

Parameters:
index - for which to return value for
Returns:
value at index

add

public void add(double value)
Add a value to the collection.

Parameters:
value - is the double-type value to add

remove

public void remove(double value)
Remove a value from the collection.

Parameters:
value - to remove
Throws:
IllegalStateException - if the value has not been added

getValues

protected ArrayList<Double> getValues()
Returns underlying ArrayList, for testing purposes only.

Returns:
sorted double values list

findInsertIndex

protected int findInsertIndex(double value)
Returns the index into which to insert to. Proptected access level for convenient testing.

Parameters:
value - to find insert index
Returns:
position to insert the value to, or -1 to indicate to add to the end.