Class RefCountedSet<K>
java.lang.Object
com.espertech.esper.common.internal.collection.RefCountedSet<K>
reference-counting set based on a HashMap 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.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a key to the set.void
Add a key to the set with the given number of references.void
clear()
Clear out the collection.Returns an iterator over the entry set.int
Returns a key iterator.static RefCountedSet<Double>
readPointsDouble
(DataInput input) NOTE: Code-generation-invoked method, method name and parameter order mattersboolean
Removed a key to the set.boolean
Remove a key from the set regardless of the number of references.void
setNumValues
(int numValues) int
size()
Returns the number of values in the collection.static void
writePointsDouble
(DataOutput output, RefCountedSet<Double> valueSet) NOTE: Code-generation-invoked method, method name and parameter order matters
-
Field Details
-
EPTYPE
-
-
Constructor Details
-
RefCountedSet
public RefCountedSet()Constructor. -
RefCountedSet
-
-
Method Details
-
clear
public void clear()Clear out the collection. -
add
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. Return true if this is the first time the key was encountered, or false if key is already in set.- Parameters:
key
- to add- Returns:
- true if the key is not in the set already, false if the key is already in the set
-
add
Add a key to the set with the given number of references.- Parameters:
key
- to addnumReferences
- initial number of references
-
remove
Removed a key to 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. Return true if the reference count was one and the key thus removed, or false if key is stays in set.- Parameters:
key
- to add- Returns:
- true if the key is removed, false if it stays in the set
- Throws:
IllegalStateException
- is a key is removed that wasn't added to the map
-
removeAll
Remove a key from the set regardless of the number of references.- Parameters:
key
- to add- Returns:
- true if the key is removed, false if the key was not found
- Throws:
IllegalStateException
- if a key is removed that wasn't added to the map
-
entryIterator
Returns an iterator over the entry set.- Returns:
- entry set iterator
-
keyIterator
Returns a key iterator.- Returns:
- key iterator
-
size
public int size()Returns the number of values in the collection.- Returns:
- size
-
getRefSet
-
getNumValues
public int getNumValues() -
setNumValues
public void setNumValues(int numValues) -
writePointsDouble
public static void writePointsDouble(DataOutput output, RefCountedSet<Double> valueSet) throws IOException NOTE: Code-generation-invoked method, method name and parameter order matters- Parameters:
output
- outputvalueSet
- values- Throws:
IOException
- io error
-
readPointsDouble
NOTE: Code-generation-invoked method, method name and parameter order matters- Parameters:
input
- input- Returns:
- values
- Throws:
IOException
- io error
-