Class ConcurrentCountingMap<T>

java.lang.Object
soot.jimple.infoflow.collect.ConcurrentCountingMap<T>
All Implemented Interfaces:
ConcurrentMap<T,Integer>, Map<T,Integer>

public class ConcurrentCountingMap<T> extends Object implements ConcurrentMap<T,Integer>
A map that associates an element with a number. This map will never return a null value, but will pre-initialize all counters with a default value of zero.
Author:
Steven Arzt
  • Constructor Details

    • ConcurrentCountingMap

      public ConcurrentCountingMap()
    • ConcurrentCountingMap

      public ConcurrentCountingMap(int size)
    • ConcurrentCountingMap

      public ConcurrentCountingMap(Map<T,AtomicInteger> map)
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Map<T,Integer>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<T,Integer>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<T,Integer>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<T,Integer>
    • get

      public Integer get(Object key)
      Specified by:
      get in interface Map<T,Integer>
    • put

      public Integer put(T key, Integer value)
      Specified by:
      put in interface Map<T,Integer>
    • remove

      public Integer remove(Object key)
      Specified by:
      remove in interface Map<T,Integer>
    • putAll

      public void putAll(Map<? extends T,? extends Integer> m)
      Specified by:
      putAll in interface Map<T,Integer>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<T,Integer>
    • keySet

      public Set<T> keySet()
      Specified by:
      keySet in interface Map<T,Integer>
    • values

      public Collection<Integer> values()
      Specified by:
      values in interface Map<T,Integer>
    • entrySet

      public Set<Map.Entry<T,Integer>> entrySet()
      Specified by:
      entrySet in interface Map<T,Integer>
    • putIfAbsent

      public Integer putIfAbsent(T key, Integer value)
      Specified by:
      putIfAbsent in interface ConcurrentMap<T,Integer>
      Specified by:
      putIfAbsent in interface Map<T,Integer>
    • remove

      public boolean remove(Object key, Object value)
      Specified by:
      remove in interface ConcurrentMap<T,Integer>
      Specified by:
      remove in interface Map<T,Integer>
    • replace

      public boolean replace(T key, Integer oldValue, Integer newValue)
      Specified by:
      replace in interface ConcurrentMap<T,Integer>
      Specified by:
      replace in interface Map<T,Integer>
    • replace

      public Integer replace(T key, Integer value)
      Specified by:
      replace in interface ConcurrentMap<T,Integer>
      Specified by:
      replace in interface Map<T,Integer>
    • increment

      public int increment(T key)
      Increments the counter associated with the given value by one
      Parameters:
      key - The key of the value for which to increment the counter
      Returns:
      The new counter value
    • increment

      public int increment(T key, int delta)
      Increments the counter associated with the given value by the given delta
      Parameters:
      key - The key of the value for which to increment the counter
      delta - The delta by which to increment the counter
      Returns:
      The new counter value
    • decrement

      public int decrement(T key)
      Decrements the counter associated with the given value by one
      Parameters:
      key - The key of the value for which to decrement the counter
      Returns:
      The new counter value
    • getByValue

      public Set<T> getByValue(int value)
      Gets all keys that have the given value. Note that values are free to change at any time, so the set returned by this method may contain keys that have other values as well in case they were mutated by a different thread while this method was running.
      Parameters:
      value - The expected value
      Returns:
      A set with all keys that have the given value
    • setLockingMode

      public void setLockingMode(ConcurrentCountingMap.LockingMode lockingMode)
      Sets how whether and how this class shall perform locking
      Parameters:
      lockingMode - The new locking mode
    • snapshot

      public ConcurrentCountingMap<T> snapshot()
      Creates a snapshot of this map
      Returns:
      A copy of the current state of this map
    • snapshot

      public ConcurrentCountingMap<T> snapshot(Collection<T> subset)
      Creates a partial snapshot of this map
      Parameters:
      subset - The subset of element for which to create a partial snapshot
      Returns:
      A copy of the current state of this map
    • getChangeCounter

      public int getChangeCounter()
      Gets the current state of the change counter. This counter is modified whenever the contents of the map are changed.
      Returns:
      The current value of the change counter