- java.lang.Object
-
- org.hsqldb.map.BaseHashMap
-
- org.hsqldb.lib.HashMap<K,V>
-
- org.hsqldb.lib.OrderedHashMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
public class OrderedHashMap<K,V> extends HashMap<K,V>
A Map which maintains the insertion order of the key/value pairs and allows access by index. Iterators return the keys or values in the index order.This class does not store null keys.
- Since:
- 1.7.2
- Author:
- Fred Toussi (fredt@users dot sourceforge.net)
-
-
Constructor Summary
Constructors Constructor Description OrderedHashMap()
OrderedHashMap(int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(K key, V value)
V
get(int index)
Same as getValueAt(index).int
getIndex(K key)
K
getKeyAt(int index)
Returns the key stored in the entry at index position.V
getValueAt(int index)
Returns the value stored in the entry at index position.boolean
insert(int index, K key, V value)
V
remove(java.lang.Object key)
void
removeEntry(int index)
boolean
set(int index, K key, V value)
boolean
setKeyAt(int index, K key)
V
setValueAt(int index, V value)
-
Methods inherited from class org.hsqldb.lib.HashMap
containsKey, containsValue, entrySet, get, keySet, keysToArray, put, putAll, remove, values, valuesToArray
-
-
-
-
Method Detail
-
getKeyAt
public K getKeyAt(int index) throws java.lang.IndexOutOfBoundsException
Returns the key stored in the entry at index position.- Parameters:
index
- the index of the entry- Returns:
- the value stored in the entry
- Throws:
java.lang.IndexOutOfBoundsException
- for invalid argument
-
getValueAt
public V getValueAt(int index) throws java.lang.IndexOutOfBoundsException
Returns the value stored in the entry at index position.- Parameters:
index
- the index of the entry- Returns:
- the value stored in the entry
- Throws:
java.lang.IndexOutOfBoundsException
- for invalid argument
-
get
public V get(int index) throws java.lang.IndexOutOfBoundsException
Same as getValueAt(index).- Parameters:
index
- the index of the entry- Returns:
- the value stored in the entry
- Throws:
java.lang.IndexOutOfBoundsException
- for invalid argument
-
remove
public V remove(java.lang.Object key)
-
removeEntry
public void removeEntry(int index) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
setValueAt
public V setValueAt(int index, V value) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
insert
public boolean insert(int index, K key, V value) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
set
public boolean set(int index, K key, V value) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
setKeyAt
public boolean setKeyAt(int index, K key) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
getIndex
public int getIndex(K key)
-
-