|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Counter<E>
An Object to double map used for keeping weights or counts for objects.
Utility functions are contained in
Counters
. The class previously known as Counter has been
renamed to ClassicCounter
. An alternative Counter
implementation, which is more memory efficient but not necessarily faster,
is OpenAddressCounter
.
Implementation note: You shouldn't casually add further methods to
this interface. Rather, they should be added to the Counters
class.
Method Summary | |
---|---|
void |
addAll(Counter<E> counter)
Adds the counts in the given Counter to the counts in this Counter. |
void |
clear()
Removes all entries from the counter. |
boolean |
containsKey(E key)
Returns whether a Counter contains a key. |
double |
decrementCount(E key)
Decrements the count for this key by 1.0. |
double |
decrementCount(E key,
double value)
Decrements the count for this key by the given value. |
double |
defaultReturnValue()
Returns the default return value. |
java.util.Set<java.util.Map.Entry<E,java.lang.Double>> |
entrySet()
Returns a view of the entries in this counter. |
double |
getCount(java.lang.Object key)
Returns the count for this key as a double. |
Factory<Counter<E>> |
getFactory()
Returns a factory that can create new instances of this kind of Counter. |
double |
incrementCount(E key)
Increments the count for this key by 1.0. |
double |
incrementCount(E key,
double value)
Increments the count for the given key by the given value. |
java.util.Set<E> |
keySet()
Returns the Set of keys in this counter. |
double |
logIncrementCount(E key,
double value)
Increments the count stored in log space for this key by the given log-transformed value. |
double |
remove(E key)
Removes the given key and its associated value from this Counter. |
void |
setCount(E key,
double value)
Sets the count for the given key to be the given value. |
void |
setDefaultReturnValue(double rv)
Sets the default return value. |
int |
size()
Returns the number of entries stored in this counter. |
double |
totalCount()
Computes the total of all counts in this counter, and returns it as a double. |
java.util.Collection<java.lang.Double> |
values()
Returns a copy of the values currently in this counter. |
Method Detail |
---|
Factory<Counter<E>> getFactory()
void setDefaultReturnValue(double rv)
rv
- The default valuedouble defaultReturnValue()
double getCount(java.lang.Object key)
key
- The key
void setCount(E key, double value)
incrementCount(Object,double)
.
key
- The keyvalue
- The countdouble incrementCount(E key, double value)
incrementCount(Object)
.
To set a count to a specific value instead of incrementing it, use
setCount(Object,double)
.
key
- The key to incrementvalue
- The amount to increment it by
double incrementCount(E key)
incrementCount(Object,double)
.
To set a count to a specific value instead of incrementing it, use
setCount(Object,double)
.
key
- The key to increment by 1.0
double decrementCount(E key, double value)
incrementCount
.
To more conveniently decrement the count by 1.0, use
decrementCount(Object)
.
To set a count to a specific value instead of decrementing it, use
setCount(Object,double)
.
key
- The key to decrementvalue
- The amount to decrement it by
double decrementCount(E key)
decrementCount(Object,double)
.
To set a count to a specific value instead of decrementing it, use
setCount(Object,double)
.
key
- The key to decrement by 1.0
double logIncrementCount(E key, double value)
setCount(Object,double)
.
key
- The key to incrementvalue
- The amount to increment it by, in log space
void addAll(Counter<E> counter)
counter
- The Counter whose counts will be added. For each key in
counter, if it is not in this, then it will be added with value
counter.getCount(key)
. Otherwise, it will have value
this.getCount(key) + counter.getCount(key)
.double remove(E key)
key
- The key
boolean containsKey(E key)
key
- The key
java.util.Set<E> keySet()
java.util.Collection<java.lang.Double> values()
java.util.Set<java.util.Map.Entry<E,java.lang.Double>> entrySet()
void clear()
int size()
double totalCount()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |