Parsing Engine

danbikel.parser
Interface CountsTable<K>

All Superinterfaces:
Map<K,Object>, MapToPrimitive<K>
All Known Implementing Classes:
CountsTableImpl, FileBackedTrainerEventMap

public interface CountsTable<K>
extends MapToPrimitive<K>

Specifies a mapping between objects and floating-point (double) counts that may be incremented or decremented.


Nested Class Summary
 
Nested classes/interfaces inherited from interface danbikel.util.MapToPrimitive
MapToPrimitive.Entry<K>
 
Method Summary
 void add(K key)
          Adds the specified key with a count of 1.0.
 void addAll(CountsTable<K> other)
          Adds all the counts from the specified table to this table, adding any new keys in the specified map to this map, if necessary.
 double count(K key)
          Returns the count of the specified key, or 0 if this counts table does not contain a count for the specified key.
 double count(K key, int hashCode)
          Returns the count of the specified key with the specified hash code, or 0 if this counts table does not contain a count for the specified key.
 void output(String eventName, Writer writer)
          Outputs all the mappings of this map in as S-expressions of the form (name key value)
 void putAll(CountsTable<K> other)
          Puts the specified map of key objects to their counts into this counts table.
 void removeItemsBelow(double threshold)
          Removes items in this table whose counts are less than the specified threshold.
 
Methods inherited from interface danbikel.util.MapToPrimitive
add, add, add, add, add, add, add, add, add, add, add, add, getEntry, getEntry, getEntryMRU, getEntryMRU, put, put, put, put, put, put, put, put, put, put, put, put, put, put, removeRandom, removeRandom
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

addAll

void addAll(CountsTable<K> other)
Adds all the counts from the specified table to this table, adding any new keys in the specified map to this map, if necessary.

Parameters:
other - the other counts table whose counts are to be added to this table

putAll

void putAll(CountsTable<K> other)
Puts the specified map of key objects to their counts into this counts table. If a key from the specified map already exists in this map, it is simply replaced.

Parameters:
other - another counts table whose counts are to be put into this table

add

void add(K key)
Adds the specified key with a count of 1.0.

Parameters:
key - the key to be added to this counts table

count

double count(K key)
Returns the count of the specified key, or 0 if this counts table does not contain a count for the specified key.

Parameters:
key - the key whose count is to be gotten
Returns:
the count of the specified key, or 0 if this counts table does not contain a count for the specified key

count

double count(K key,
             int hashCode)
Returns the count of the specified key with the specified hash code, or 0 if this counts table does not contain a count for the specified key.

Parameters:
key - the key whose count is to be gotten
hashCode - the hash code of the specified key
Returns:
the count of the specified key with the specified hash code, or 0 if this counts table does not contain a count for the specified key

removeItemsBelow

void removeItemsBelow(double threshold)
Removes items in this table whose counts are less than the specified threshold.

Parameters:
threshold - the count threshold below which to remove items from this table

output

void output(String eventName,
            Writer writer)
            throws IOException
Outputs all the mappings of this map in as S-expressions of the form
(name key value)

Parameters:
eventName - the name of the events contained in this CountsTable to output as the first symbol in the three-element list
writer - the writer to which to output the elements of this counts table as three-element S-expression lists
Throws:
IOException - if there is a problem writing to the specified writer

Parsing Engine

Author: Dan Bikel.