com.rubecula.darwin.domain.world
Class FrequencyMap<T>
java.lang.Object
com.rubecula.darwin.domain.world.FrequencyMap<T>
- Type Parameters:
T
- the class representing the objects whose frequency we wish to map.
TODO consider extending AToString
- Direct Known Subclasses:
- NumericFrequencyMap, QuantifiableFrequencyMap, TraitFrequencyMap
public class FrequencyMap<T>
- extends java.lang.Object
Class to implement a frequency map.
Note that this type is not of the usual type family: there is no interface or
abstract type to support this, hence we have public non-bean methods that are
not defined in an external interface.
- Author:
- Robin Hillyard
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FrequencyMap
public FrequencyMap(java.lang.String name)
- Parameters:
name
- the identifier for this map
add
public void add(T key)
- Update the frequency map based on the given key. If key is not already
present in the map, we create a new entry with key and value 0. Then we
add 1 to the value corresponding to key.
- Parameters:
key
-
add
public void add(T key,
int increment)
- Update the frequency map based on the given key. If key is not already
present in the map, we create a new entry with key and value 0. Then we
add 1 to the value corresponding to key.
- Parameters:
key
- increment
- the amount to add to the frequency for key
clear
public void clear()
- See Also:
Map.clear()
containsKey
public boolean containsKey(T key)
- Parameters:
key
-
- Returns:
- true if the map contains a frequency for key
- See Also:
Map.containsKey(java.lang.Object)
get
public int get(T key)
- Parameters:
key
-
- Returns:
- the frequency of key (or 0 if the key is unknown)
- See Also:
Map.get(java.lang.Object)
getName
public java.lang.String getName()
- Returns:
- the name
getTotal
public int getTotal()
- Returns:
- the total of all the frequencies
isEmpty
public boolean isEmpty()
- Returns:
- true if map is empty
- See Also:
Map.isEmpty()
keySet
public java.util.Set<T> keySet()
- Returns:
- the set of values whose frequencies are known
- See Also:
Map.keySet()
log
public void log(org.apache.commons.logging.Log log)
- Parameters:
log
-
output
public void output(java.io.PrintWriter writer)
- Parameters:
writer
-
output
public void output(SinkCensus sinkCensus)
- Parameters:
sinkCensus
-
remove
public int remove(T key)
- Parameters:
key
-
- Returns:
- the value for the key before removal or 0 if the key was unknown.
- See Also:
Map.remove(java.lang.Object)
size
public int size()
- Returns:
- the number of entries in the map.
- See Also:
Map.size()
getMap
protected java.util.Map<T,Frequency> getMap()
- Returns:
- the map
Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.