public class LinkedHashSet<E>
- Object
- AbstractCollection<E>
- AbstractSet<E>
- HashSet<E>
- LinkedHashSet
ImplementsCollection<E>, Iterable<E>, Set<E>
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).
Constructors
public LinkedHashSet() | Constructs a new empty instance of LinkedHashSet. |
public LinkedHashSet(int capacity) | Constructs a new instance of LinkedHashSet with the specified capacity. |
public LinkedHashSet(int capacity, float loadFactor) | Constructs a new instance of LinkedHashSet with the specified capacity and load factor. |
public LinkedHashSet(Collection<? extends E> collection) | Constructs a new instance of LinkedHashSet containing the unique elements in the specified collection. |
Inherited methods
From AbstractSet
From Collection
Constructor details
LinkedHashSet
public LinkedHashSet()Constructs a new empty instance of
LinkedHashSet.LinkedHashSet
public LinkedHashSet(int capacity)Constructs a new instance of
LinkedHashSet with the specified
capacity.Parameters
capacityint- the initial capacity of this
LinkedHashSet.
LinkedHashSet
public LinkedHashSet(int capacity, float loadFactor)Constructs a new instance of
LinkedHashSet with the specified
capacity and load factor.Parameters
capacityint- the initial capacity.
loadFactorfloat- the initial load factor.
LinkedHashSet
public LinkedHashSet(Collection<? extends E> collection)Constructs a new instance of
LinkedHashSet containing the unique
elements in the specified collection.Parameters
collectionCollection<? extends E>- the collection of elements to add.