public class IntegerMap<T>
extends java.lang.Object
Integers must be non-negative.
Constructor and Description |
---|
IntegerMap()
Construct a new integer map with a default capacity.
|
IntegerMap(int initialCapacity)
Construct a new integer map with a given capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(int key)
Determine if the given key exists in the map.
|
protected void |
ensureCapacity(int key)
Resize the backing array to fit the given key.
|
T |
get(int key)
Retrieve the value associated with a given key.
|
static <T> IntegerMap<T> |
newMap()
Construct a new integer map.
|
T |
put(int key,
T value)
Associate an integer key with the given value.
|
T |
remove(int key)
Remove an association from the map.
|
int |
size()
Retrieve the number of mappings in this map.
|
java.util.Map<java.lang.Integer,java.lang.Object> |
toMap()
Convert the current map to an Integer map.
|
public IntegerMap()
public IntegerMap(int initialCapacity)
initialCapacity
- - the capacity.public static <T> IntegerMap<T> newMap()
public T put(int key, T value)
key
- - the integer key. Cannot be negative.value
- - the value. Cannot be NULL.public T remove(int key)
key
- - the key of the association to remove.protected void ensureCapacity(int key)
key
- - the key.public int size()
public T get(int key)
key
- - the key.public boolean containsKey(int key)
key
- - the key to check.public java.util.Map<java.lang.Integer,java.lang.Object> toMap()