Module org.jhotdraw8.icollection
Interface ImmutableSet<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
ImmutableCollection<E>,Iterable<E>,ReadOnlyCollection<E>,ReadOnlySet<E>
- All Known Subinterfaces:
ImmutableNavigableSet<E>,ImmutableSequencedSet<E>,ImmutableSortedSet<E>
- All Known Implementing Classes:
ChampSet,ChampVectorSet,ImmutableSetFacade,RedBlackSet
An interface to an immutable set; the implementation guarantees that the
state of the collection does not change.
An interface to an immutable set provides methods for creating a new immutable set with added or removed elements, without changing the original immutable 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 ImmutableSet<E> Returns a copy of this set that contains all elements of this set and also all elements of the specified collection.<T> @NonNull ImmutableSet<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 ImmutableSet<E> Returns a copy of this set that contains all elements of this set except the elements of the specified collection.default @NonNull ImmutableSet<E> Returns a copy of this set that contains only elements that are in this set and in the specified collection.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
asCollection, contains, containsAll, isEmpty, iterator, size, stream, toArray, toArrayMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySet
asSet, characteristics, equals, hashCode
-
Method Details
-
empty
Returns an empty set instance that has the specified element type.- Specified by:
emptyin interfaceImmutableCollection<E>- Type Parameters:
T- the element type of the returned set- Returns:
- an empty set of the specified element type.
-
add
Returns a copy of this set that contains all elements of this set and also the specified element.- Specified by:
addin interfaceImmutableCollection<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
Returns 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>- 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
-
remove
Returns a copy of this set that contains all elements of this set except the specified element.- Specified by:
removein interfaceImmutableCollection<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
Returns a copy of this set that contains all elements of this set except the elements of the specified collection.- Specified by:
removeAllin interfaceImmutableCollection<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
-
retainAll
Returns a copy of this set that contains only elements that are in this set and in the specified collection.- Specified by:
retainAllin interfaceImmutableCollection<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
Returns a mutable copy of this set.- Specified by:
toMutablein interfaceImmutableCollection<E>- Returns:
- a mutable copy.
-