edu.stanford.nlp.stats
Interface Counter<E>

All Known Implementing Classes:
AbstractCounter, ClassicCounter, IntCounter

public interface Counter<E>

Basic Object to double map. Utility functions are contained in Counters. Class previously known as Counter has been renamed ot ClassicCounter and many of its functions deprecated in preference to those in Counters. The preferred Counter implementation is OpenAddressCounter.

Author:
dramage, cer

Method Summary
 void clear()
          Removes all entries from the counter
 boolean containsKey(E 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.
 void defaultReturnValue(double rv)
          Sets the default return value.
 Set<Map.Entry<E,Double>> entrySet()
          Returns a view of the entries in this counter
 double getCount(E 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 this key by the given value.
 Set<E> keySet()
          Returns the Set of keys in this counter.
 double logIncrementCount(E key, double value)
          log space increments the count for this key by the given value.
 double remove(E key)
          Removes the value associated with the given key.
 void setCount(E key, double value)
          Sets the count for this key to be the given value.
 int size()
          Returns the number of entries in this counter.
 double totalCount()
          Computes the total of all counts in this counter, and returns it as a double.
 Collection<Double> values()
          Returns a copy of the values currently in this counter.
 

Method Detail

getFactory

Factory<Counter<E>> getFactory()
Returns a factory that can create new instances of this kind of Counter.

Returns:
A factory that can create new instances of this kind of Counter.

defaultReturnValue

void defaultReturnValue(double rv)
Sets the default return value.

Parameters:
rv - The default value

defaultReturnValue

double defaultReturnValue()
Returns the default return value.

Returns:
The default return value.

getCount

double getCount(E key)
Returns the count for this key as a double.

Parameters:
key - The key
Returns:
The count

setCount

void setCount(E key,
              double value)
Sets the count for this key to be the given value.

Parameters:
key - The key
value - The count

incrementCount

double incrementCount(E key,
                      double value)
Increments the count for this key by the given value.

Parameters:
key - The key to increment
value - The amount to increment it by
Returns:
The value associated with they key, post-increment.

incrementCount

double incrementCount(E key)
Increments the count for this key by 1.0.

Parameters:
key - The key to increment by 1.0
Returns:
The value associated with they key, post-increment.

decrementCount

double decrementCount(E key,
                      double value)
Decrements the count for this key by the given value.

Parameters:
key - The key to decrement
value - The amount to decrement it by
Returns:
The value associated with they key, post-decrement.

decrementCount

double decrementCount(E key)
Decrements the count for this key by 1.0.

Parameters:
key - The key to decrement by 1.0
Returns:
The value of associated with they key, post-decrement.

logIncrementCount

double logIncrementCount(E key,
                         double value)
log space increments the count for this key by the given value.

Parameters:
key - The key to increment
value - The amount to increment it by, in log space
Returns:
The value associated with they key, post-increment, in log space

remove

double remove(E key)
Removes the value associated with the given key.

Returns:
The value removed from the map or the default value if no count was associated with that key.

containsKey

boolean containsKey(E key)
Returns:
true iff key is a key in this GenericCounter.

keySet

Set<E> keySet()
Returns the Set of keys in this counter.

Returns:
The Set of keys in this counter.

values

Collection<Double> values()
Returns a copy of the values currently in this counter.


entrySet

Set<Map.Entry<E,Double>> entrySet()
Returns a view of the entries in this counter


clear

void clear()
Removes all entries from the counter


size

int size()
Returns the number of entries in this counter.


totalCount

double totalCount()
Computes the total of all counts in this counter, and returns it as a double.

Returns:
The total of all counts in this counter


Stanford NLP Group