LinkedHashSet (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements maintained by this set
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, SequencedCollection<E>, SequencedSet<E>, Set<E>
-
Constructor Summary
Constructors
Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).
LinkedHashSet(int initialCapacity) Constructs a new, empty linked hash set with the specified initial capacity and the default load factor (0.75).
LinkedHashSet(int initialCapacity, float loadFactor) Constructs a new, empty linked hash set with the specified initial capacity and load factor.
Constructs a new linked hash set with the same elements as the specified collection.
-
Method Summary
voidAdds an element as the first element of this collection (optional operation).
voidAdds an element as the last element of this collection (optional operation).
getFirst()Gets the first element of this collection.
getLast()Gets the last element of this collection.
newLinkedHashSet(int numElements) Creates a new, empty LinkedHashSet suitable for the expected number of elements.
Removes and returns the first element of this collection (optional operation).
Removes and returns the last element of this collection (optional operation).
reversed()Returns a reverse-ordered view of this collection.
Creates a late-binding and fail-fast
Spliteratorover the elements in this set.Methods declared in class HashSet
add, clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, toArray, toArraybooleanAdds the specified element to this set if it is not already present.
voidRemoves all of the elements from this set.
Returns a shallow copy of this
HashSetinstance: the elements themselves are not cloned.booleanReturns
trueif this set contains the specified element.booleanReturns
trueif this set contains no elements.Returns an iterator over the elements in this set.
Creates a new, empty HashSet suitable for the expected number of elements.
booleanRemoves the specified element from this set if it is present.
intReturns the number of elements in this set (its cardinality).
Returns an array containing all of the elements in this collection.
<T> T[]Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
Methods declared in class AbstractSet
booleanCompares the specified object with this set for equality.
intReturns the hash code value for this set.
booleanRemoves from this set all of its elements that are contained in the specified collection (optional operation).
Methods declared in class AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toStringbooleanAdds all of the elements in the specified collection to this collection (optional operation).
booleanReturns
trueif this collection contains all of the elements in the specified collection.booleanRetains only the elements in this collection that are contained in the specified collection (optional operation).
Returns an array containing all of the elements in this collection.
<T> T[]Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
Returns a string representation of this collection.
Methods declared in class Object
finalize, getClass, notify, notifyAll, wait, wait, waitprotected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
Methods declared in interface Collection
parallelStream, removeIf, stream, toArrayReturns a possibly parallel
Streamwith this collection as its source.default booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).
Returns a sequential
Streamwith this collection as its source.default <T> T[]Returns an array containing all of the elements in this collection, using the provided
generatorfunction to allocate the returned array.Methods declared in interface Iterable
default voidPerforms the given action for each element of the
Iterableuntil all elements have been processed or the action throws an exception.Methods declared in interface Set
addAll, containsAll, retainAllbooleanAdds all of the elements in the specified collection to this set if they're not already present (optional operation).
booleanReturns
trueif this set contains all of the elements of the specified collection.booleanRetains only the elements in this set that are contained in the specified collection (optional operation).
-
Constructor Details
-
LinkedHashSet
-
LinkedHashSet
-
LinkedHashSet
-
LinkedHashSet
-
-
Method Details
-
spliterator
-
newLinkedHashSet
-
addFirst
-
addLast
-
getFirst
-
getLast
-
removeFirst
-
removeLast
-
reversed
-