Module org.jhotdraw8.icollection
Interface ImmutableSortedSet<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
ImmutableCollection<E>,ImmutableSet<E>,Iterable<E>,ReadOnlyCollection<E>,ReadOnlySequencedCollection<E>,ReadOnlySequencedSet<E>,ReadOnlySet<E>,ReadOnlySortedSet<E>
- All Known Subinterfaces:
ImmutableNavigableSet<E>
- All Known Implementing Classes:
RedBlackSet
An interface to an immutable sorted set; the implementation guarantees that the state of the collection does not change.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this set that contains all elements of this set and also the specified element.default @NonNull ImmutableSortedSet<E> Returns a copy of this set that contains all elements of this set and also all elements of the specified collection.<T> @NonNull ImmutableSortedSet<T> empty()Returns an empty set instance that has the specified element type.<T> @NonNull ImmutableCollection<T> empty(@Nullable Comparator<T> comparator) Returns a copy of this collection that is empty, and has the specified type and comparator.Returns a copy of this set that contains all elements of this set except the specified element.default @NonNull ImmutableSortedSet<E> Returns a copy of this set that contains all elements of this set except the elements of the specified collection.default ImmutableSortedSet<E> Returns a copy of this set that contains all elements of this set except the first.default ImmutableSortedSet<E> Returns a copy of this set that contains all elements of this set except the last.default @NonNull ImmutableSortedSet<E> Returns a copy of this set that contains only elements that are in this set and in the specified collection.default @NonNull ImmutableSortedSet<E> reversed()Returns a mutable copy of this set.Methods inherited from interface org.jhotdraw8.icollection.immutable.ImmutableCollection
filter, maxSizeMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyCollection
contains, containsAll, isEmpty, iterator, size, stream, toArray, toArrayMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySequencedCollection
asCollection, getFirst, getLastMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySequencedSet
asSet, readOnlyReversedMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySet
characteristics, equals, hashCodeMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySortedSet
comparator
-
Method Details
-
add
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set and also the specified element.- Specified by:
addin interfaceImmutableCollection<E>- Specified by:
addin interfaceImmutableSet<E>- Parameters:
element- an element- Returns:
- this set instance if it already contains the element, or a different set instance with the element added
-
addAll
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set and also all elements of the specified collection.- Specified by:
addAllin interfaceImmutableCollection<E>- Specified by:
addAllin interfaceImmutableSet<E>- Parameters:
c- a collection to be added to this set- Returns:
- this set instance if it already contains the elements, or a different set instance with the elements added
-
empty
Description copied from interface:ImmutableSetReturns an empty set instance that has the specified element type.- Specified by:
emptyin interfaceImmutableCollection<E>- Specified by:
emptyin interfaceImmutableSet<E>- Type Parameters:
T- the element type of the returned set- Returns:
- an empty set of the specified element type.
-
empty
Returns a copy of this collection that is empty, and has the specified type and comparator.- Type Parameters:
T- the element type of the collection- Parameters:
comparator- a comparator for ordering the elements of the set, specifynullto use the natural order of the elements- Returns:
- an empty collection of the specified type and comparator
-
remove
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set except the specified element.- Specified by:
removein interfaceImmutableCollection<E>- Specified by:
removein interfaceImmutableSet<E>- Parameters:
element- an element- Returns:
- this set instance if it already does not contain the element, or a different set instance with the element removed
-
removeAll
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set except the elements of the specified collection.- Specified by:
removeAllin interfaceImmutableCollection<E>- Specified by:
removeAllin interfaceImmutableSet<E>- Parameters:
c- a collection with elements to be removed from this set- Returns:
- this set instance if it already does not contain the elements, or a different set instance with the elements removed
-
removeFirst
Returns a copy of this set that contains all elements of this set except the first.- Returns:
- a new set instance with the first element removed
- Throws:
NoSuchElementException- if this set is empty
-
removeLast
Returns a copy of this set that contains all elements of this set except the last.- Returns:
- a new set instance with the last element removed
- Throws:
NoSuchElementException- if this set is empty
-
retainAll
Description copied from interface:ImmutableSetReturns a copy of this set that contains only elements that are in this set and in the specified collection.- Specified by:
retainAllin interfaceImmutableCollection<E>- Specified by:
retainAllin interfaceImmutableSet<E>- Parameters:
c- a collection with elements to be retained in this set- Returns:
- this set instance if it has not changed, or a different set instance with elements removed
-
toMutable
@NonNull NavigableSet<E> toMutable()Description copied from interface:ImmutableSetReturns a mutable copy of this set.- Specified by:
toMutablein interfaceImmutableCollection<E>- Specified by:
toMutablein interfaceImmutableSet<E>- Returns:
- a mutable copy.
-
reversed
-