E - Element type to storepublic class ConcurrentHashCounter<E> extends java.lang.Object implements java.io.Serializable, Counter<E>, java.lang.Iterable<E>
| Constructor and Description |
|---|
ConcurrentHashCounter() |
ConcurrentHashCounter(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
equals(java.lang.Object o) |
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.
|
int |
hashCode()
Returns a hashCode which is the underlying Map's hashCode.
|
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.Iterator<E> |
iterator() |
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.
|
void |
prettyLog(Redwood.RedwoodChannels channels,
java.lang.String description)
Pretty logs the current object to specific Redwood channels.
|
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 value)
Sets the default return value.
|
int |
size()
Returns the number of entries stored in this counter.
|
java.lang.String |
toString()
Returns a String representation of the Counter, as formatted by
the underlying Map.
|
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.
|
public ConcurrentHashCounter()
public ConcurrentHashCounter(int initialCapacity)
public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>public Factory<Counter<E>> getFactory()
CountergetFactory in interface Counter<E>public void setDefaultReturnValue(double value)
CountersetDefaultReturnValue in interface Counter<E>value - The default valuepublic double defaultReturnValue()
CounterdefaultReturnValue in interface Counter<E>public double getCount(java.lang.Object key)
Counterpublic void setCount(E key, double value)
CounterCounter.incrementCount(Object,double).public double incrementCount(E key, double value)
CounterCounter.incrementCount(Object).
To set a count to a specific value instead of incrementing it, use
Counter.setCount(Object,double).incrementCount in interface Counter<E>key - The key to incrementvalue - The amount to increment it bypublic double incrementCount(E key)
CounterCounter.incrementCount(Object,double).
To set a count to a specific value instead of incrementing it, use
Counter.setCount(Object,double).incrementCount in interface Counter<E>key - The key to increment by 1.0public double decrementCount(E key, double value)
CounterincrementCount.
To more conveniently decrement the count by 1.0, use
Counter.decrementCount(Object).
To set a count to a specific value instead of decrementing it, use
Counter.setCount(Object,double).decrementCount in interface Counter<E>key - The key to decrementvalue - The amount to decrement it bypublic double decrementCount(E key)
CounterCounter.decrementCount(Object,double).
To set a count to a specific value instead of decrementing it, use
Counter.setCount(Object,double).decrementCount in interface Counter<E>key - The key to decrement by 1.0public double logIncrementCount(E key, double value)
CounterCounter.setCount(Object,double).logIncrementCount in interface Counter<E>key - The key to incrementvalue - The amount to increment it by, in log spacepublic void addAll(Counter<E> counter)
Counterpublic double remove(E key)
Counterpublic boolean containsKey(E key)
CountercontainsKey in interface Counter<E>key - The keypublic java.util.Set<E> keySet()
Counterpublic java.util.Collection<java.lang.Double> values()
Counterpublic java.util.Set<java.util.Map.Entry<E,java.lang.Double>> entrySet()
Counterpublic void clear()
Counterpublic int size()
Counterpublic double totalCount()
CountertotalCount in interface Counter<E>public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic void prettyLog(Redwood.RedwoodChannels channels, java.lang.String description)
PrettyLoggableprettyLog in interface PrettyLoggablechannels - the channels which should be logged to -- all logging calls should
use logging methods on the channels (e.g. channels.log(), etc.)description - The description of the object. It will potentially identify the
object's functional role or (failing that) its class. This is
typically used as a track name surrounding the contents of this
object.