LinkedHashSetpublic class LinkedHashSet extends HashSet implements Serializable, Set, CloneableLinkedHashSet 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
{@link Collections#synchronizedSet(Set)}. |
Fields Summary |
---|
private static final long | serialVersionUID |
Constructors Summary |
---|
public LinkedHashSet()Constructs a new empty instance of {@code LinkedHashSet}.
super(new LinkedHashMap<E, HashSet<E>>());
| public LinkedHashSet(int capacity)Constructs a new instance of {@code LinkedHashSet} with the specified
capacity.
super(new LinkedHashMap<E, HashSet<E>>(capacity));
| public LinkedHashSet(int capacity, float loadFactor)Constructs a new instance of {@code LinkedHashSet} with the specified
capacity and load factor.
super(new LinkedHashMap<E, HashSet<E>>(capacity, loadFactor));
| public LinkedHashSet(Collection collection)Constructs a new instance of {@code LinkedHashSet} containing the unique
elements in the specified collection.
super(new LinkedHashMap<E, HashSet<E>>(collection.size() < 6 ? 11
: collection.size() * 2));
for (E e : collection) {
add(e);
}
|
Methods Summary |
---|
java.util.HashMap | createBackingMap(int capacity, float loadFactor)
return new LinkedHashMap<E, HashSet<E>>(capacity, loadFactor);
|
|