Module org.hsqldb

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