com.espertech.esper.collection
Class SortedRefCountedSet<K>

java.lang.Object
  extended by com.espertech.esper.collection.SortedRefCountedSet<K>

public class SortedRefCountedSet<K>
extends java.lang.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
SortedRefCountedSet()
          Constructor.
 
Method Summary
 void add(K key)
          Add a key to the set.
 void add(K key, int numReferences)
          Add a key to the set with the given number of references.
 void clear()
          Clear out the collection.
 long getCountPoints()
          Returns the number of data points.
 java.util.TreeMap<K,java.lang.Integer> getRefSet()
           
 K maxValue()
          Returns the largest key value, or null if the collection is empty.
 K minValue()
          Returns the smallest key value, or null if the collection is empty.
 void remove(K key)
          Remove a key from the set.
 void setCountPoints(long countPoints)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedRefCountedSet

public SortedRefCountedSet()
Constructor.

Method Detail

clear

public void clear()
Clear out the collection.


add

public void add(K key)
Add a key to the set. Add with a reference count of one if the key didn't exist in the set. Increase the reference count by one if the key already exists.

Parameters:
key - to add

add

public void add(K key,
                int numReferences)
Add a key to the set with the given number of references.

Parameters:
key - to add
numReferences - initial number of references

remove

public void remove(K key)
Remove a key from the set. Removes the key if the reference count is one. Decreases the reference count by one if the reference count is more then one.

Parameters:
key - to add
Throws:
java.lang.IllegalStateException - is a key is removed that wasn't added to the map

maxValue

public K maxValue()
Returns the largest key value, or null if the collection is empty.

Returns:
largest key value, null if none

minValue

public K minValue()
Returns the smallest key value, or null if the collection is empty.

Returns:
smallest key value, null if none

getCountPoints

public long getCountPoints()
Returns the number of data points.

Returns:
point count

getRefSet

public java.util.TreeMap<K,java.lang.Integer> getRefSet()

setCountPoints

public void setCountPoints(long countPoints)

© 2006-2016 EsperTech Inc.
All rights reserved.
Visit us at espertech.com