net.i2p.util
Class ObjectCounter<K>

java.lang.Object
  extended by net.i2p.util.ObjectCounter<K>

public class ObjectCounter<K>
extends java.lang.Object

Count things.

Author:
zzz

Constructor Summary
ObjectCounter()
           
 
Method Summary
 void clear()
          start over
 int count(K h)
           
 int increment(K h)
          Add one.
 java.util.Set<K> objects()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectCounter

public ObjectCounter()
Method Detail

increment

public int increment(K h)
Add one. Not perfectly concurrent, new AtomicInteger(1) would be better, at the cost of some object churn.

Returns:
count after increment

count

public int count(K h)
Returns:
current count

objects

public java.util.Set<K> objects()
Returns:
set of objects with counts > 0

clear

public void clear()
start over

Since:
0.7.11