K - type of objects being countedpublic class ObjectCounter<K> extends Object implements Serializable
This class provides a concurrent way to count how many times specific objects appear. It uses ConcurrentHashMap and AtomicInteger to ensure thread-safe operations in multi-threaded environments.
Typical use cases include:
| Constructor and Description |
|---|
ObjectCounter() |
ObjectCounter(int maxSize) |
public ObjectCounter()
public ObjectCounter(int maxSize)
maxSize - Maximum number of entries before oldest are evictedpublic void clear()
public void clear(K h)
public int count(K h)
public int increment(K h)
public void max(K h)