|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<T,Integer>
com.googlecode.whatswrong.javautils.Counter<T>
public class Counter<T>
A Counter counts objects of class T.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Constructor Summary | |
|---|---|
Counter()
|
|
| Method Summary | |
|---|---|
Integer |
get(Object o)
Gets the count of object o. |
int |
getMaximum()
Gets the maximum count of all objects in the counter. |
void |
increment(T value,
int howmuch)
Increments the count for the given object by howmuch |
static Counter<String> |
loadFromFile(File file)
Loads counts from a column separated file where row looks like "value count". |
void |
save(OutputStream outputStream)
Saves the counts to column separated text file with format "value count" in each row. |
List<Map.Entry<T,Integer>> |
sorted(boolean descending)
Sort map entries by counts. |
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, entrySet, 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 |
| Constructor Detail |
|---|
public Counter()
| Method Detail |
|---|
public Integer get(Object o)
get in interface Map<T,Integer>get in class HashMap<T,Integer>o - the object to get the count of.
public void increment(T value,
int howmuch)
howmuch
value - the object to increment the count for.howmuch - how much the count should be incremented.
public static Counter<String> loadFromFile(File file)
throws IOException
file - the file to load from.
IOException - if I/O goes wrong.public List<Map.Entry<T,Integer>> sorted(boolean descending)
descending - the list start with the highest or lowest count.
public void save(OutputStream outputStream)
outputStream - the output stream to print to.public int getMaximum()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||