Interface ImmutableSequencedSet<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
ImmutableCollection<E>,ImmutableSequencedCollection<E>,ImmutableSet<E>,Iterable<E>,ReadOnlyCollection<E>,ReadOnlySequencedCollection<E>,ReadOnlySequencedSet<E>,ReadOnlySet<E>
- All Known Implementing Classes:
ChampVectorSet
An interface to an immutable sequenced set provides methods for creating a new immutable sequenced set with added or removed elements, without changing the original immutable sequenced set.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this set that contains all elements of this set and also the specified element.default @NonNull ImmutableSequencedSet<E> Returns a copy of this set that contains all elements of this set and also all elements of the specified collection.Returns a copy of this collection that contains all elements of this collection and also the specified element as the first element in the iteration order.Returns a copy of this collection that contains all elements of this collection and also the specified element as the last element in the iteration order.<T> @NonNull ImmutableSequencedSet<T> empty()Returns an empty set instance that has the specified element type.Returns a copy of this set that contains all elements of this set except the specified element.default @NonNull ImmutableSequencedSet<E> Returns a copy of this set that contains all elements of this set except the elements of the specified collection.default ImmutableSequencedSet<E> Returns a copy of this set that contains all elements of this set except the first.default ImmutableSequencedSet<E> Returns a copy of this set that contains all elements of this set except the last.default @NonNull ImmutableSequencedSet<E> Returns a copy of this set that contains only elements that are in this set and in the specified collection.default @NonNull ImmutableSequencedSet<E> reverse()Returns a reversed copy of this set.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, hashCode
-
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 interfaceImmutableSequencedCollection<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 interfaceImmutableSequencedCollection<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
-
addFirst
Description copied from interface:ImmutableSequencedCollectionReturns a copy of this collection that contains all elements of this collection and also the specified element as the first element in the iteration order.A collection may prevent that the same element can be added more than once.
If the iteration order is based on an ordering relation of the elements, then the element is only the first in a sequence of elements with the same ordering relation; which is not necessarily the first in the total iteration order.
- Specified by:
addFirstin interfaceImmutableSequencedCollection<E>- Parameters:
element- an element- Returns:
- this collection instance if it already contains the element as the first in the iteration order, or a different collection instance with the element added as the first in the iteration order
-
addLast
Description copied from interface:ImmutableSequencedCollectionReturns a copy of this collection that contains all elements of this collection and also the specified element as the last element in the iteration order.A collection may prevent that the same element can be added more than once.
If the iteration order is based on an ordering relation of the elements, then the element is only the last in a sequence of elements with the same ordering relation; which is not necessarily the last in the total iteration order.
- Specified by:
addLastin interfaceImmutableSequencedCollection<E>- Parameters:
element- an element- Returns:
- this collection instance if it already contains the element as the last in the iteration order, or a different collection instance with the element added as the last in the iteration order
-
empty
Description copied from interface:ImmutableSetReturns an empty set instance that has the specified element type.- Specified by:
emptyin interfaceImmutableCollection<E>- Specified by:
emptyin interfaceImmutableSequencedCollection<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.
-
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 interfaceImmutableSequencedCollection<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 interfaceImmutableSequencedCollection<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.- Specified by:
removeFirstin interfaceImmutableSequencedCollection<E>- 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.- Specified by:
removeLastin interfaceImmutableSequencedCollection<E>- 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 interfaceImmutableSequencedCollection<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 SequencedSet<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.
-
reverse
Returns a reversed copy of this set.This operation may be implemented in O(N).
Use
ReadOnlySequencedSet.readOnlyReversed()if you only need to iterate in the reversed sequence over this set.- Returns:
- a reversed copy of this set.
-