public class ArrayMap<T> extends AbstractMap<Integer,T> implements Serializable
Map implementation for integer keys, which backed by an array.
This class provides a bridge between array-based data structures and
Collections-based APIs that require mappings from integer keys to values.
This map does not permit null values or keys. Furthermore, all
keys must be in the range of [0,l] where l is the length of the original
array. Attempts to add new mappings outside this range will cause an IllegalArgumentException, all other operations that exceed this boundary
will return null or false where appropriate.
All mutating methods to the entry set and iterators will throw UnsupportedOperationException if called.
The size() operation runs in linear time upon first call and is
constant time for all subsequent calls.
This map is not thread safe.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
ArrayMap(T[] array) |
ArrayMap(T[] array,
int sizeOfMap) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object key) |
Set<Map.Entry<Integer,T>> |
entrySet() |
T |
get(Object key) |
int |
maxKey()
Returns the largest
Integer key allowed by this map. |
T |
put(Integer key,
T value) |
T |
remove(Object key) |
int |
size() |
public ArrayMap(T[] array, int sizeOfMap)
public ArrayMap(T[] array)
public boolean containsKey(Object key)
containsKey in interface Map<Integer,T>containsKey in class AbstractMap<Integer,T>public boolean containsValue(Object key)
containsValue in interface Map<Integer,T>containsValue in class AbstractMap<Integer,T>public int maxKey()
Integer key allowed by this map.public T put(Integer key, T value)
put in interface Map<Integer,T>put in class AbstractMap<Integer,T>IllegalArgumentException - if key < 0 or key >
maxKey(), or if value is null.Copyright © 2012. All Rights Reserved.