public class SimpleArrayMap<K,V>
extends java.lang.Object
| Constructor and Description |
|---|
SimpleArrayMap()
Create a new empty ArrayMap.
|
SimpleArrayMap(int capacity)
Create a new ArrayMap with a given initial capacity.
|
SimpleArrayMap(SimpleArrayMap map)
Create a new ArrayMap with the mappings from the given ArrayMap.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Make the array map empty.
|
boolean |
containsKey(java.lang.Object key)
Check whether a key exists in the array.
|
boolean |
containsValue(java.lang.Object value)
Check whether a value exists in the array.
|
void |
ensureCapacity(int minimumCapacity)
Ensure the array map can hold at least minimumCapacity
items.
|
boolean |
equals(java.lang.Object object) |
V |
get(java.lang.Object key)
Retrieve a value from the array.
|
int |
hashCode() |
int |
indexOfKey(java.lang.Object key)
Returns the index of a key in the set.
|
boolean |
isEmpty()
Return true if the array map contains no items.
|
K |
keyAt(int index)
Return the key at the given index in the array.
|
V |
put(K key,
V value)
Add a new value to the array map.
|
void |
putAll(SimpleArrayMap<? extends K,? extends V> array)
Perform a
put(Object, Object) of all key/value pairs in array |
V |
remove(java.lang.Object key)
Remove an existing key from the array map.
|
V |
removeAt(int index)
Remove the key/value mapping at the given index.
|
V |
setValueAt(int index,
V value)
Set the value at a given index in the array.
|
int |
size()
Return the number of items in this array map.
|
java.lang.String |
toString() |
V |
valueAt(int index)
Return the value at the given index in the array.
|
public SimpleArrayMap()
public SimpleArrayMap(int capacity)
public SimpleArrayMap(SimpleArrayMap map)
public void clear()
public void ensureCapacity(int minimumCapacity)
public boolean containsKey(java.lang.Object key)
key - The key to search for.public int indexOfKey(java.lang.Object key)
key - The key to search for.public boolean containsValue(java.lang.Object value)
value - The value to search for.public V get(java.lang.Object key)
key - The key of the value to retrieve.public K keyAt(int index)
index - The desired index, must be between 0 and size()-1.public V valueAt(int index)
index - The desired index, must be between 0 and size()-1.public V setValueAt(int index, V value)
index - The desired index, must be between 0 and size()-1.value - The new value to store at this index.public boolean isEmpty()
public V put(K key, V value)
key - The key under which to store the value. Must not be null. If
this key already exists in the array, its value will be replaced.value - The value to store for the given key.public void putAll(SimpleArrayMap<? extends K,? extends V> array)
put(Object, Object) of all key/value pairs in arrayarray - The array whose contents are to be retrieved.public V remove(java.lang.Object key)
key - The key of the mapping to remove.public V removeAt(int index)
index - The desired index, must be between 0 and size()-1.public int size()
public boolean equals(java.lang.Object object)
This implementation returns false if the object is not a map, or if the maps have different sizes. Otherwise, for each key in this map, values of both maps are compared. If the values for any key are not equal, the method returns false, otherwise it returns true.
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
This implementation composes a string by iterating over its mappings. If this map contains itself as a key or a value, the string "(this Map)" will appear in its place.
toString in class java.lang.Object