Package net.i2p.util
Class ObjectCounterUnsafe<K>
- java.lang.Object
-
- net.i2p.util.ObjectCounterUnsafe<K>
-
public class ObjectCounterUnsafe<K> extends Object
Count things. NOT thread safe, mostly for UI and Sybil. Dropin replacement for ObjectCounter. Much less object churn than ObjectCounter. Also provides add() and sortedObjects()- Since:
- 0.9.58
-
-
Constructor Summary
Constructors Constructor Description ObjectCounterUnsafe()
-
-
-
Method Detail
-
increment
public int increment(K h)
Add one.- Returns:
- count after increment
-
add
public int add(K h, int val)
Add a value- Returns:
- count after adding
-
count
public int count(K h)
- Returns:
- current count
-
sortedObjects
public List<K> sortedObjects()
- Returns:
- list of objects reverse sorted by count, highest to lowest
-
clear
public void clear()
Start over. Reset the count for all keys to zero.
-
clear
public void clear(K h)
Reset the count for this key to zero
-
-