Package games.stendhal.server.util
Class CounterMap<T>
java.lang.Object
games.stendhal.server.util.CounterMap<T>
- Type Parameters:
T
- type of object
counts how often objects are added
- Author:
- hendrik
-
Constructor Summary
ConstructorDescriptioncreates a new counter map.CounterMap(boolean weak)
creates a new counter map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
increments the counter of the specified objectvoid
increments the counter of the specified objectvoid
clear()
clears the counting and starts at 0 again.entrySet()
Get the set of counted objects and their counts.int
gets the number the specified object was coutnedgets the object with the highest amountkeySet()
Get the set of counted objects.
-
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
increments the counter of the specified object- Parameters:
object
- object to count
-
add
increments the counter of the specified object- Parameters:
object
- object to countinc
- the amount to increment
-
getCount
gets the number the specified object was coutned- Parameters:
object
- object- Returns:
- number
-
getHighestCountedObject
gets the object with the highest amount- Returns:
- object with highest amount
-
entrySet
Get the set of counted objects and their counts.- Returns:
- count entries
-
keySet
Get the set of counted objects.- Returns:
- counted objects
-