Module org.hsqldb

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)
  • Constructor Details

    • OrderedHashSet

      public OrderedHashSet()
    • OrderedHashSet

      public OrderedHashSet(int initialCapacity)
    • OrderedHashSet

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

      public OrderedHashSet(E[] valueList)
  • Method Details

    • 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 IndexOutOfBoundsException
      Throws:
      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 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(Object key)
    • getIndex

      public int getIndex(Object key)
    • lastIndexOf

      public int lastIndexOf(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