Module org.hsqldb

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