Module org.hsqldb
Package org.hsqldb.lib

## Class OrderedHashMap<K,​V>

- 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)

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.hsqldb.lib.Map

      `Map.Entry<K,​V>`

  - ### Field Summary

    - ### Fields inherited from class org.hsqldb.map.BaseHashMap

      `ACCESS_MAX, emptyObjectArray`

  - ### 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`

    - ### Methods inherited from class org.hsqldb.map.BaseHashMap

      `clear, clone, isEmpty, size`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.hsqldb.lib.Map

      `clear, isEmpty, size`

- - ### Constructor Detail

    - #### OrderedHashMap

          public OrderedHashMap()

    - #### OrderedHashMap

          public OrderedHashMap​(int initialCapacity)
                         throws java.lang.IllegalArgumentException

      Throws:
        `java.lang.IllegalArgumentException`

  - ### 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)

      Specified by:
        `remove` in interface `Map<K,​V>`
      Overrides:
        `remove` in class `HashMap<K,​V>`

    - #### removeEntry

          public void removeEntry​(int index)
                           throws java.lang.IndexOutOfBoundsException

      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### add

          public boolean add​(K key,
                             V value)

    - #### 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)