Interface SequencedSet<E>
- Type Parameters:
E- the type of elements in this sequenced set
- All Superinterfaces:
Collection<E>, Iterable<E>, SequencedCollection<E>, Set<E>
- All Known Subinterfaces:
NavigableSet<E>, SortedSet<E>
- All Known Implementing Classes:
ConcurrentSkipListSet, LinkedHashSet, TreeSet
A collection that is both a
SequencedCollection and a Set. As such,
it can be thought of either as a Set that also has a well-defined
encounter order, or as a
SequencedCollection that also has unique elements.
This interface has the same requirements on the equals and hashCode
methods as defined by Set.equals and Set.hashCode.
Thus, a Set and a SequencedSet will compare equals if and only
if they have equal elements, irrespective of ordering.
SequencedSet defines the reversed() method, which provides a
reverse-ordered view of this set. The only difference
from the SequencedCollection.reversed method is
that the return type of SequencedSet.reversed is SequencedSet.
This class is a member of the Java Collections Framework.
- Since:
- 21
-
Method Summary
Methods declared in interface Collection
parallelStream, removeIf, stream, toArrayModifier and TypeMethodDescriptionReturns a possibly parallelStreamwith this collection as its source.default booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).stream()Returns a sequentialStreamwith this collection as its source.default <T> T[]toArray(IntFunction<T[]> generator) Returns an array containing all of the elements in this collection, using the providedgeneratorfunction to allocate the returned array.Methods declared in interface SequencedCollection
addFirst, addLast, getFirst, getLast, removeFirst, removeLastModifier and TypeMethodDescriptiondefault voidAdds an element as the first element of this collection (optional operation).default voidAdds an element as the last element of this collection (optional operation).default EgetFirst()Gets the first element of this collection.default EgetLast()Gets the last element of this collection.default ERemoves and returns the first element of this collection (optional operation).default ERemoves and returns the last element of this collection (optional operation).Methods declared in interface Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArrayModifier and TypeMethodDescriptionbooleanAdds the specified element to this set if it is not already present (optional operation).booleanaddAll(Collection<? extends E> c) Adds all of the elements in the specified collection to this set if they're not already present (optional operation).voidclear()Removes all of the elements from this set (optional operation).booleanReturnstrueif this set contains the specified element.booleancontainsAll(Collection<?> c) Returnstrueif this set contains all of the elements of the specified collection.booleanCompares the specified object with this set for equality.inthashCode()Returns the hash code value for this set.booleanisEmpty()Returnstrueif this set contains no elements.iterator()Returns an iterator over the elements in this set.booleanRemoves the specified element from this set if it is present (optional operation).booleanremoveAll(Collection<?> c) Removes from this set all of its elements that are contained in the specified collection (optional operation).booleanretainAll(Collection<?> c) Retains only the elements in this set that are contained in the specified collection (optional operation).intsize()Returns the number of elements in this set (its cardinality).default Spliterator<E> Creates aSpliteratorover the elements in this set.Object[]toArray()Returns an array containing all of the elements in this set.<T> T[]toArray(T[] a) Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
-
Method Details
-
reversed
SequencedSet<E> reversed()Returns a reverse-ordered view of this collection. The encounter order of elements in the returned view is the inverse of the encounter order of elements in this collection. The reverse ordering affects all order-sensitive operations, including those on the view collections of the returned view. If the collection implementation permits modifications to this view, the modifications "write through" to the underlying collection. Changes to the underlying collection might or might not be visible in this reversed view, depending upon the implementation.- Specified by:
reversedin interfaceSequencedCollection<E>- Returns:
- a reverse-ordered view of this collection, as a
SequencedSet
-