public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, Serializable
Null elements are allowed, and all the optional Set operations are supported.
Like HashSet, LinkedHashSet is not thread safe, so access by multiple threads
must be synchronized by an external mechanism such as
Collections.synchronizedSet(Set).
| Constructor and Description |
|---|
LinkedHashSet()
Constructs a new empty instance of
LinkedHashSet. |
LinkedHashSet(Collection<? extends E> collection)
Constructs a new instance of
LinkedHashSet containing the unique
elements in the specified collection. |
LinkedHashSet(int capacity)
Constructs a new instance of
LinkedHashSet with the specified
capacity. |
LinkedHashSet(int capacity,
float loadFactor)
Constructs a new instance of
LinkedHashSet with the specified
capacity and load factor. |
| Modifier and Type | Method and Description |
|---|---|
Spliterator<E> |
spliterator()
Creates a late-binding
and fail-fast
Spliterator over the elements in this set. |
add, clear, clone, contains, isEmpty, iterator, remove, sizeequals, hashCode, removeAlladdAll, containsAll, retainAll, toArray, toArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, contains, containsAll, copyOf, equals, hashCode, isEmpty, iterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, removeAll, retainAll, size, toArray, toArrayforEach, parallelStream, removeIf, stream, toArraypublic LinkedHashSet()
LinkedHashSet.public LinkedHashSet(int capacity)
LinkedHashSet with the specified
capacity.capacity - the initial capacity of this LinkedHashSet.public LinkedHashSet(int capacity,
float loadFactor)
LinkedHashSet with the specified
capacity and load factor.capacity - the initial capacity.loadFactor - the initial load factor.public LinkedHashSet(Collection<? extends E> collection)
LinkedHashSet containing the unique
elements in the specified collection.collection - the collection of elements to add.public Spliterator<E> spliterator()
Spliterator over the elements in this set.
The Spliterator reports Spliterator.SIZED,
Spliterator.DISTINCT, and ORDERED. Implementations
should document the reporting of additional characteristic values.
spliterator in interface Iterable<E>spliterator in interface Collection<E>spliterator in interface Set<E>Spliterator over the elements in this set