Class CounterMap<T>

java.lang.Object
games.stendhal.server.util.CounterMap<T>
Type Parameters:
T - type of object

public class CounterMap<T> extends Object
counts how often objects are added
Author:
hendrik
  • Constructor Details

    • CounterMap

      public CounterMap()
      creates a new counter map.
    • CounterMap

      public CounterMap(boolean weak)
      creates a new counter map.
      Parameters:
      weak - true to create a weak key map, false to create a normal map
  • Method Details

    • clear

      public void clear()
      clears the counting and starts at 0 again.
    • add

      public void add(T object)
      increments the counter of the specified object
      Parameters:
      object - object to count
    • add

      public void add(T object, int inc)
      increments the counter of the specified object
      Parameters:
      object - object to count
      inc - the amount to increment
    • getCount

      public int getCount(T object)
      gets the number the specified object was coutned
      Parameters:
      object - object
      Returns:
      number
    • getHighestCountedObject

      public T getHighestCountedObject()
      gets the object with the highest amount
      Returns:
      object with highest amount
    • entrySet

      public Set<Map.Entry<T,​Integer>> entrySet()
      Get the set of counted objects and their counts.
      Returns:
      count entries
    • keySet

      public Set<T> keySet()
      Get the set of counted objects.
      Returns:
      counted objects