Class IntegerMap<T>
java.lang.Object
com.comphenix.protocol.collections.IntegerMap<T>
Represents a very quick integer-based lookup map, with a fixed key space size.
Integers must be non-negative.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new integer map with a default capacity.IntegerMap(int initialCapacity) Construct a new integer map with a given capacity. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(int key) Determine if the given key exists in the map.protected voidensureCapacity(int key) Resize the backing array to fit the given key.get(int key) Retrieve the value associated with a given key.Associate an integer key with the given value.remove(int key) Remove an association from the map.intsize()Retrieve the number of mappings in this map.toMap()Convert the current map to an Integer map.
-
Constructor Details
-
IntegerMap
public IntegerMap()Construct a new integer map with a default capacity. -
IntegerMap
public IntegerMap(int initialCapacity) Construct a new integer map with a given capacity.- Parameters:
initialCapacity- - the capacity.
-
-
Method Details
-
put
Associate an integer key with the given value.- Parameters:
key- - the integer key. Cannot be negative.value- - the value. Cannot be NULL.- Returns:
- The previous association, or NULL if not found.
-
remove
Remove an association from the map.- Parameters:
key- - the key of the association to remove.- Returns:
- The old associated value, or NULL.
-
ensureCapacity
protected void ensureCapacity(int key) Resize the backing array to fit the given key.- Parameters:
key- - the key.
-
size
public int size()Retrieve the number of mappings in this map.- Returns:
- The number of mapping.
-
get
Retrieve the value associated with a given key.- Parameters:
key- - the key.- Returns:
- The value, or NULL if not found.
-
containsKey
public boolean containsKey(int key) Determine if the given key exists in the map.- Parameters:
key- - the key to check.- Returns:
- TRUE if it does, FALSE otherwise.
-
toMap
Convert the current map to an Integer map.- Returns:
- The Integer map.
-