Module org.hsqldb
Package org.hsqldb.lib

## Class OrderedHashSet<E>

- java.lang.Object
- - org.hsqldb.map.BaseHashMap
  - - org.hsqldb.lib.HashSet<E>
    - - org.hsqldb.lib.OrderedHashSet<E>

- All Implemented Interfaces:
    `Collection<E>`, `List<E>`, `Set<E>`

      public class OrderedHashSet<E>
      extends HashSet<E>
      implements List<E>, Set<E>

  A list which is also a Set which maintains the inserted order of elements and allows access by index. Iterators return the elements in the index order.

  This class does not store null elements.

  Since:
    1.9.0
  Author:
    Fred Toussi (fredt@users dot sourceforge.net)

- - ### Field Summary

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

      `ACCESS_MAX, emptyObjectArray`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OrderedHashSet()` |
    `OrderedHashSet​(int initialCapacity)` |
    `OrderedHashSet​(int initialCapacity, ObjectComparator<E> comparator)` |
    `OrderedHashSet​(E[] valueList)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(int index, E key)` |
    `static <E> OrderedHashSet<E>` | `add​(OrderedHashSet<E> first, E value)` | add value to first.
    `static <E> OrderedHashSet<E>` | `addAll​(OrderedHashSet<E> first, OrderedHashSet<E> second)` | add all elements of second to first.
    `E` | `get​(int index)` |
    `int` | `getCommonElementCount​(Set<E> other)` |
    `int` | `getIndex​(java.lang.Object key)` |
    `int` | `getLargestIndex​(OrderedHashSet<E> other)` |
    `int` | `getSmallestIndex​(OrderedHashSet<E> other)` |
    `int` | `indexOf​(java.lang.Object key)` |
    `boolean` | `insert​(int index, E key)` |
    `int` | `lastIndexOf​(java.lang.Object o)` |
    `E` | `remove​(int index)` |
    `boolean` | `remove​(E key)` | returns true if removed
    `E` | `set​(int index, E key)` |
    `java.lang.Object[]` | `toArray()` |
    `<T> T[]` | `toArray​(T[] array)` |

    - ### Methods inherited from class org.hsqldb.lib.HashSet

      `add, addAll, addAll, addAll, capacity, contains, containsAll, get, getOrAdd, iterator, removeAll, removeAll, toString`

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

      `clear, clone, isEmpty, size`

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

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

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

      `addAll, clear, contains`

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

      `add, isEmpty, iterator, size`

- - ### Constructor Detail

    - #### OrderedHashSet

          public OrderedHashSet()

    - #### OrderedHashSet

          public OrderedHashSet​(int initialCapacity)

    - #### OrderedHashSet

          public OrderedHashSet​(int initialCapacity,
                                ObjectComparator<E> comparator)

    - #### OrderedHashSet

          public OrderedHashSet​(E[] valueList)

  - ### Method Detail

    - #### remove

          public boolean remove​(E key)

      Description copied from class: `HashSet`
      returns true if removed
      Specified by:
        `remove` in interface `Collection<E>`
      Overrides:
        `remove` in class `HashSet<E>`
      Parameters:
        `key` - Object to remove
      Returns:
        true if removed

    - #### remove

          public E remove​(int index)

      Specified by:
        `remove` in interface `List<E>`

    - #### insert

          public boolean insert​(int index,
                                E key)
                         throws java.lang.IndexOutOfBoundsException

      Throws:
        `java.lang.IndexOutOfBoundsException`

    - #### set

          public E set​(int index,
                       E key)

      Specified by:
        `set` in interface `List<E>`

    - #### add

          public void add​(int index,
                          E key)

      Specified by:
        `add` in interface `List<E>`

    - #### get

          public E get​(int index)

      Specified by:
        `get` in interface `List<E>`

    - #### toArray

          public java.lang.Object[] toArray()

      Overrides:
        `toArray` in class `HashSet<E>`

    - #### toArray

          public <T> T[] toArray​(T[] array)

      Overrides:
        `toArray` in class `HashSet<E>`

    - #### indexOf

          public int indexOf​(java.lang.Object key)

    - #### getIndex

          public int getIndex​(java.lang.Object key)

    - #### lastIndexOf

          public int lastIndexOf​(java.lang.Object o)

    - #### getLargestIndex

          public int getLargestIndex​(OrderedHashSet<E> other)

    - #### getSmallestIndex

          public int getSmallestIndex​(OrderedHashSet<E> other)

    - #### getCommonElementCount

          public int getCommonElementCount​(Set<E> other)

      Overrides:
        `getCommonElementCount` in class `HashSet<E>`

    - #### addAll

          public static <E> OrderedHashSet<E> addAll​(OrderedHashSet<E> first,
                                                     OrderedHashSet<E> second)

      add all elements of second to first. if second is null return first (which can be null), else if first is null return a new set and add the elements of second

    - #### add

          public static <E> OrderedHashSet<E> add​(OrderedHashSet<E> first,
                                                  E value)

      add value to first. if value is null return first (which can be null), else if first is null return a new set and add the value