E - the type of values in this mappublic class IntMap<E>
extends java.lang.Object
Class IntMap represents a map with integer keys and generic type
values.
Class IntMap is not thread-safe.
| Constructor | Description |
|---|---|
IntMap(int capacity) |
Creates a new
IntMap instance. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
clear() |
Removes all keys from this map.
|
boolean |
contains(int key) |
Returns
true if the map contains the specified key,
and returns false otherwise. |
E |
get(int key) |
Returns the value for the specified key or
null
if the specified key is not present in this map. |
int |
key(int index) |
Returns the specified key.
|
int[] |
keys() |
Returns an array containing the keys in this map.
|
E |
put(int key,
E value) |
Adds the specified key and value to this map.
|
E |
remove(int key) |
Removes the specified key from this map, and returns the value
previously associated with the key or
null if no such
value exists. |
int |
size() |
Returns the number of keys in this map.
|
java.lang.String |
toString() |
Returns
java.util.Arrays.toString(this.keys()). |
java.util.List<E> |
values() |
Returns a list containing the values in this map.
|
public IntMap(int capacity)
IntMap instance.capacity - the initial capacity of this mapjava.lang.IllegalArgumentException - if
capacity < 0 || (capacity > (1 << 30))public void clear()
public boolean contains(int key)
true if the map contains the specified key,
and returns false otherwise.key - a keytrue if the map contains the specified keypublic E put(int key, E value)
key - the keyvalue - the valuenull if
there did not exist a value for the specified keypublic E remove(int key)
null if no such
value exists. The indexing of keys immediately before and after
this method is invoked may differ if this map is changed by
this operation.key - a key indexnull if
there did not exist a value for the specified keypublic int key(int index)
index - an index of a key in this mapjava.lang.IndexOutOfBoundsException - if
index < 0 || index >= this.size()public E get(int key)
null
if the specified key is not present in this map.key - the keypublic int size()
public int[] keys()
this.toArray()[j]==this.key(j) for each
j satisfying (0 <= j && j < this.size()).public java.util.List<E> values()
this.get(this.keys()[j])==this.values.get(j) for each
j satisfying (0 <= j && j < this.size()).public java.lang.String toString()
java.util.Arrays.toString(this.keys()).toString in class java.lang.Objectjava.util.Arrays.toString(this.keys())