- 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 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 removedE
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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hsqldb.lib.Collection
addAll, clear, contains
-
-
-
-
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
-
insert
public boolean insert(int index, E key) throws java.lang.IndexOutOfBoundsException
- Throws:
java.lang.IndexOutOfBoundsException
-
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 classHashSet<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
-
-