Package java.util
Class LinkedHashSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet<E>
-
- java.util.LinkedHashSet<E>
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,Set<E>
public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, Serializable
LinkedHashSet is a variant of HashSet. Its entries are kept in a doubly-linked list. The iteration order is the order in which entries were inserted.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).- Since:
- 1.4
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LinkedHashSet()Constructs a new empty instance ofLinkedHashSet.LinkedHashSet(int capacity)Constructs a new instance ofLinkedHashSetwith the specified capacity.LinkedHashSet(int capacity, float loadFactor)Constructs a new instance ofLinkedHashSetwith the specified capacity and load factor.LinkedHashSet(Collection<? extends E> collection)Constructs a new instance ofLinkedHashSetcontaining the unique elements in the specified collection.
-
Method Summary
-
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size
-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
-
-
-
-
Constructor Detail
-
LinkedHashSet
public LinkedHashSet()
Constructs a new empty instance ofLinkedHashSet.
-
LinkedHashSet
public LinkedHashSet(int capacity)
Constructs a new instance ofLinkedHashSetwith the specified capacity.- Parameters:
capacity- the initial capacity of thisLinkedHashSet.
-
LinkedHashSet
public LinkedHashSet(int capacity, float loadFactor)Constructs a new instance ofLinkedHashSetwith the specified capacity and load factor.- Parameters:
capacity- the initial capacity.loadFactor- the initial load factor.
-
LinkedHashSet
public LinkedHashSet(Collection<? extends E> collection)
Constructs a new instance ofLinkedHashSetcontaining the unique elements in the specified collection.- Parameters:
collection- the collection of elements to add.
-
-