|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.collections.CounterSet<E>
public class CounterSet<E>
This class manages a set of counters (i.e. is a mapping from some key objects to integers). As the implementation is based on hash maps, key objects must provide suitable hash keys.
Field Summary | |
---|---|
protected java.util.Map<E,java.lang.Integer> |
map
The underlying map. |
protected int |
total
Stores total value. |
Constructor Summary | |
---|---|
CounterSet()
|
Method Summary | |
---|---|
boolean |
contains(E key)
Checks if an element is stored in the array. |
UnmodifiableSet<E> |
getKeys()
Returns the set of all elements used a keys for counters. |
int |
getTotal()
Get total sum of all elements. |
int |
getValue(E key)
Get the value for an element. |
void |
inc(E key)
Same as inc(key, 1) . |
void |
inc(E key,
int increment)
Add the given increment to an element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.util.Map<E,java.lang.Integer> map
protected int total
Constructor Detail |
---|
public CounterSet()
Method Detail |
---|
public void inc(E key, int increment)
key
- the key of the counter to increment.increment
- the increment.public void inc(E key)
inc(key, 1)
.
inc(Object, int)
public boolean contains(E key)
public int getValue(E key)
0
is returned.
public UnmodifiableSet<E> getKeys()
public int getTotal()
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |