net.sourceforge.cobertura.coveragedata.countermaps
Class AtomicCounterMap<T>

java.lang.Object
  extended by net.sourceforge.cobertura.coveragedata.countermaps.AtomicCounterMap<T>
Type Parameters:
T -
All Implemented Interfaces:
CounterMap<T>, HasBeenInstrumented

public class AtomicCounterMap<T>
extends java.lang.Object
implements CounterMap<T>, HasBeenInstrumented

Thread-safe implementation of map that counts number of keys (like multi-set)

Author:
ptab

Field Summary
private  java.util.concurrent.ConcurrentMap<T,java.util.concurrent.atomic.AtomicInteger> counters
           
 
Constructor Summary
AtomicCounterMap()
           
 
Method Summary
 java.util.Map<T,java.lang.Integer> getFinalStateAndCleanIt()
           
 int getSize()
           
 int getValue(T key)
           
 void incrementValue(T key)
           
 void incrementValue(T key, int inc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counters

private final java.util.concurrent.ConcurrentMap<T,java.util.concurrent.atomic.AtomicInteger> counters
Constructor Detail

AtomicCounterMap

public AtomicCounterMap()
Method Detail

incrementValue

public final void incrementValue(T key,
                                 int inc)
Specified by:
incrementValue in interface CounterMap<T>

incrementValue

public final void incrementValue(T key)
Specified by:
incrementValue in interface CounterMap<T>

getValue

public final int getValue(T key)
Specified by:
getValue in interface CounterMap<T>

getFinalStateAndCleanIt

public java.util.Map<T,java.lang.Integer> getFinalStateAndCleanIt()
Specified by:
getFinalStateAndCleanIt in interface CounterMap<T>

getSize

public int getSize()