K - The class we want to countpublic class Counter<K> extends HashMap<K,Integer>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
Counter() |
Counter(Counter<K> c)
Copy constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(K k)
Increases the value of k by 1.
|
void |
add(K k,
int i)
Increases the value of k by i.
|
void |
addAll(Collection<? extends K> arg)
Increases the value of all elements in arg by 1.
|
static Counter<String> |
fromString(Reader r)
A static function that creates a
Counter<String>
object from a stream. |
Integer |
get(Object k) |
int |
getHighestCount()
Returns the maximal number
|
Set<K> |
getKeysWithMaxCount() |
org.apache.commons.math3.util.Pair<Integer,Set<K>> |
getMax()
Returns a pair with the maximal value and all elements that have it.
|
org.apache.commons.math3.util.Pair<Integer,Set<K>> |
getMin()
Returns a pair with the maximal value and all elements that have it.
|
void |
subtract(K k)
Decreases the value of k by 1.
|
void |
subtractAll(Collection<? extends K> arg)
Decreases the value of all elements in arg by 1.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesequals, hashCode, toStringpublic void add(K k)
k - the object we countpublic void add(K k, int i)
k - The counteei - The amountpublic void subtract(K k)
k - the counteepublic void addAll(Collection<? extends K> arg)
arg - a collection of counteespublic void subtractAll(Collection<? extends K> arg)
arg - a collection of counteespublic org.apache.commons.math3.util.Pair<Integer,Set<K>> getMax()
public org.apache.commons.math3.util.Pair<Integer,Set<K>> getMin()
public int getHighestCount()
public Set<K> getKeysWithMaxCount()
public static Counter<String> fromString(Reader r) throws IOException
Counter<String>
object from a stream. The function assumes that string and count are
separated by a tab character.r - The reader object from which we read.IOException - thrown in case of IO exceptionsCopyright © 2016. All rights reserved.