org.archive.util
Class Histotable<K>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,java.lang.Long>
org.archive.util.Histotable<K>
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<K,java.lang.Long>
- Direct Known Subclasses:
- CrawledBytesHistotable
public class Histotable<K>
- extends java.util.HashMap<K,java.lang.Long>
Collect and report frequency information.
Assumes external synchornization.
- Author:
- gojomo
- See Also:
- Serialized Form
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Method Summary |
long |
add(Histotable<K> ht)
|
static java.lang.String |
entryString(java.lang.Object e)
Utility method to convert a key->Long into
the string "count key". |
long |
getLargestValue()
Return the largest value of any key that is larger than 0. |
java.util.TreeSet |
getSortedByCounts()
|
java.util.TreeSet |
getSortedByKeys()
|
long |
getTotal()
Return the total of all tallies. |
long |
subtract(Histotable<K> ht)
|
void |
tally(K key)
Record one more occurence of the given object key. |
void |
tally(K key,
long count)
Record count more occurence(s) of the given object key. |
Methods inherited from class java.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Histotable
public Histotable()
tally
public void tally(K key)
- Record one more occurence of the given object key.
- Parameters:
key
- Object key.
tally
public void tally(K key,
long count)
- Record count more occurence(s) of the given object key.
- Parameters:
key
- Object key.
getSortedByCounts
public java.util.TreeSet getSortedByCounts()
- Returns:
- Return an up-to-date sorted version of the totalled info.
getSortedByKeys
public java.util.TreeSet getSortedByKeys()
- Returns:
- Return an up-to-date sorted version of the totalled info.
getLargestValue
public long getLargestValue()
- Return the largest value of any key that is larger than 0. If no
values or no value larger than zero, return zero.
- Returns:
- long largest value or zero if none larger than zero
getTotal
public long getTotal()
- Return the total of all tallies.
- Returns:
- long total of all tallies
entryString
public static java.lang.String entryString(java.lang.Object e)
- Utility method to convert a key->Long into
the string "count key".
- Parameters:
e
- Map key.
- Returns:
- String 'count key'.
add
public long add(Histotable<K> ht)
subtract
public long subtract(Histotable<K> ht)
Copyright © 2003-2011 Internet Archive. All Rights Reserved.