danbikel.parser
Class BiCountsTable<K>
java.lang.Object
java.util.AbstractMap<K,Object>
danbikel.util.AbstractMapToPrimitive<K>
danbikel.util.HashMapPrimitive<K>
danbikel.util.HashMapDouble<K>
danbikel.util.HashMapTwoDoubles<K>
danbikel.parser.BiCountsTable<K>
- All Implemented Interfaces:
- FlexibleMap<K,Object>, MapToPrimitive<K>, Serializable, Cloneable, Map<K,Object>
public class BiCountsTable<K>
- extends HashMapTwoDoubles<K>
Provides a mapping between objects and two floating-point (double)
values that may be incremented or decremented.
- See Also:
- Serialized Form
Constructor Summary |
BiCountsTable()
Constructs an empty BiCountsTable . |
BiCountsTable(int initialCapacity)
Constructs an empty BiCountsTable with the specified initial
number of hash buckets. |
BiCountsTable(int initialCapacity,
float loadFactor)
Constructs an empty BiCountsTable with the specified initial
number of hash buckets and the specified load factor. |
Method Summary |
void |
add(K key,
int index)
Adds 1 to the counter at the specified index for the specified key in
this map. |
double |
count(K key,
int index)
Returns the value at the specified index 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 count0 count1)
where count0 is the integer at index 0 and count1
is the integer at index 1 for the key. |
void |
removeItemsBelow(double threshold,
int atIndex)
Removes items in this table whose counts are less than the specified
threshold. |
Methods inherited from class danbikel.util.HashMapPrimitive |
add, add, add, add, add, add, addEntryMRU, containsKey, entrySet, get, getCapacity, getEntry, getEntry, getEntryMRU, getEntryMRU, getLoadFactor, getOrCreateEntry, getStats, put, put, put, put, put, put, put, put, remove, removeLRU, removeLRU, removeRandom |
Methods inherited from class danbikel.util.AbstractMapToPrimitive |
add, add, add, add, add, put, put, put, put, put, put, put, removeRandom, toString |
Methods inherited from class java.util.AbstractMap |
clear, clone, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, size, values |
BiCountsTable
public BiCountsTable()
- Constructs an empty
BiCountsTable
.
BiCountsTable
public BiCountsTable(int initialCapacity)
- Constructs an empty
BiCountsTable
with the specified initial
number of hash buckets.
- Parameters:
initialCapacity
- the number of hash buckets that this object
will initially have
BiCountsTable
public BiCountsTable(int initialCapacity,
float loadFactor)
- Constructs an empty
BiCountsTable
with the specified initial
number of hash buckets and the specified load factor. If the load factor,
which is average number of items per bucket, is exceeded at runtime, the
number of buckets is roughly doubled and the entire map is re-hashed, as
implemented by the parent class, HashMap
.
- Parameters:
initialCapacity
- the number of hash buckets that this object will
initially haveloadFactor
- the load factor of this HashMap
object
add
public void add(K key,
int index)
- Adds 1 to the counter at the specified index for the specified key in
this map. If no such key exists, then a mapping is added, with 1 as
the value of the counter at the specified index and 0 as the value of
all other counters (this map contains only two counters).
- Specified by:
add
in interface MapToPrimitive<K>
- Overrides:
add
in class AbstractMapToPrimitive<K>
- Parameters:
key
- the key whose count at the specified index is to be incrementedindex
- the index of the counter to be incremented for the specified
key
count
public double count(K key,
int index)
- Returns the value at the specified index for the specified key.
- Parameters:
key
- the key to be looked upindex
- the index of a value associated with the specified key
- Returns:
- the value at the specified index for the specified key, or
0.0 if the key is not in this map
removeItemsBelow
public void removeItemsBelow(double threshold,
int atIndex)
- 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 tableatIndex
- the index at which to check an item's count to see if
it falls below the specified threshold; the value of this argument
must be either 0 or 1
output
public void output(String eventName,
Writer writer)
throws IOException
- Outputs all the mappings of this map in as S-expressions of the form
(name key count0 count1)
where count0 is the integer at index 0 and count1
is the integer at index 1 for the key.
- Parameters:
eventName
- the name of this type of event, to be the first element
of the 4-element S-expression output by this methodwriter
- the character stream to which this map's entries are to
be written
- Throws:
IOException
- if the specified Writer throws an
IOException while it is being written to
Author: Dan Bikel.