- Type Parameters:
E- the type of elements contained in the set. The persistent set is covariant on its element type.
- All Superinterfaces:
ImmutableCollection<E>, ImmutableSet<E>, Iterable<E>, PersistentCollection<E>
A generic persistent unordered collection of elements that does not support duplicate elements, and supports adding and removing elements.
Modification operations return new instances of the persistent set with the modification applied.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePersistentSet.Builder<E extends @Nullable Object>A generic builder of the persistent set. -
Method Summary
Modifier and TypeMethodDescriptionReturns the result of adding the specifiedelementto this set.default PersistentSet<E> Returns the result of adding all elements of the specifiedelementsarray to this set.default PersistentSet<E> Returns the result of adding all elements of the specifiedelementscollection to this set.addAll(Collection<? extends E> elements) Returns the result of adding all elements of the specifiedelementscollection to this set.default PersistentSet<E> Returns the result of adding all elements of the specifiedelementssequence to this set.builder()Returns a new builder with the same contents as this collection.clear()Returns an empty persistent set.static PersistentSet<Character> from(CharSequence chars) Returns a persistent set of all characters.static <T extends @Nullable Object>
PersistentSet<T> Returns a persistent set of all elements of the specified collection.static <T extends @Nullable Object>
PersistentSet<T> Returns a persistent set of all elements of the specified sequence.static <T extends @Nullable Object>
PersistentSet<T> from(T[] array) Returns a persistent set of all elements of the specified array.static PersistentSet<Character> hashFrom(CharSequence chars) Returns a persistent set of all characters.static <T extends @Nullable Object>
PersistentSet<T> Returns a persistent set containing all elements from the specified collection.static <T extends @Nullable Object>
PersistentSet<T> Returns a persistent set of all elements of the specified sequence.static <T extends @Nullable Object>
PersistentSet<T> hashFrom(T[] array) Returns a persistent set of all elements of the specified array.static <E extends @Nullable Object>
PersistentSet<E> hashOf()Returns an empty persistent set.static <E extends @Nullable Object>
PersistentSet<E> hashOf(E... elements) Returns a new persistent set with the given elements.default PersistentSet<E> Returns all elements in this set that are also contained in the specifiedelementscollection.default PersistentSet<E> static <E extends @Nullable Object>
PersistentSet<E> of()Returns an empty persistent set.static <E extends @Nullable Object>
PersistentSet<E> of(E... elements) Returns a new persistent set with the given elements.Returns the result of removing the specifiedelementfrom this set.default PersistentSet<E> Returns the result of removing all elements in this set that are also contained in the specifiedelementsarray.default PersistentSet<E> Returns the result of removing all elements in this set that are also contained in the specifiedelementscollection.removeAll(Collection<? extends E> elements) Returns the result of removing all elements in this set that are also contained in the specifiedelementscollection.Returns the result of removing all elements in this set that match the specifiedpredicate.default PersistentSet<E> Returns the result of removing all elements in this set that are also contained in the specifiedelementssequence.retainAll(Collection<? extends E> elements) Returns all elements in this set that are also contained in the specifiedelementscollection.Methods inherited from interface ImmutableCollection
contains, containsAll, isEmpty, iterator, parallelStream, size, streamMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
of
Returns an empty persistent set. -
of
Returns a new persistent set with the given elements.
Elements of the returned set are iterated in the order they were specified.
-
hashOf
Returns an empty persistent set. -
hashOf
Returns a new persistent set with the given elements.
Order of the elements in the returned set is unspecified.
-
from
Returns a persistent set of all elements of the specified collection.
If the specified collection is already a persistent set, returns it as is. If the specified collection is a persistent set builder, calls
buildon it and returns the result.Elements of the returned set are iterated in the same order as in the specified collection.
-
from
Returns a persistent set of all elements of the specified array.
Elements of the returned set are iterated in the same order as in the specified array.
-
from
Returns a persistent set of all elements of the specified sequence.
Elements of the returned set are iterated in the same order as in the specified sequence.
-
from
Returns a persistent set of all characters.
Elements of the returned set are iterated in the same order as in the specified char sequence.
-
hashFrom
Returns a persistent set containing all elements from the specified collection.
If the specified collection is already a persistent hash set, returns it as is. If the specified collection is a persistent hash set builder, calls
buildon it and returns the result.Order of the elements in the returned set is unspecified.
-
hashFrom
Returns a persistent set of all elements of the specified array.
Order of the elements in the returned set is unspecified.
-
hashFrom
Returns a persistent set of all elements of the specified sequence.
Order of the elements in the returned set is unspecified.
-
hashFrom
Returns a persistent set of all characters.
Order of the elements in the returned set is unspecified.
-
add
Returns the result of adding the specifiedelementto this set.- Specified by:
addin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with the specified
elementadded; or this instance if it already contains the element.
-
addAll
Returns the result of adding all elements of the specifiedelementscollection to this set.- Specified by:
addAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements of the specified
elementscollection added; or this instance if it already contains every element of the specified collection.
-
remove
Returns the result of removing the specifiedelementfrom this set.- Specified by:
removein interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with the specified
elementremoved; or this instance if there is no such element in this set.
-
removeAll
Returns the result of removing all elements in this set that are also contained in the specifiedelementscollection.- Specified by:
removeAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements in this set that are also
contained in the specified
elementscollection removed; or this instance if no modifications were made in the result of this operation.
-
removeAll
Returns the result of removing all elements in this set that match the specifiedpredicate.- Specified by:
removeAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements matching the specified
predicateremoved; or this instance if no elements match the predicate.
-
retainAll
Returns all elements in this set that are also contained in the specifiedelementscollection.- Specified by:
retainAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements in this set that are also
contained in the specified
elementscollection; or this instance if no modifications were made in the result of this operation.
-
clear
PersistentSet<E> clear()Returns an empty persistent set.- Specified by:
clearin interfacePersistentCollection<E extends @Nullable Object>
-
builder
PersistentSet.Builder<E> builder()Description copied from interface:PersistentCollectionReturns a new builder with the same contents as this collection.
The builder can be used to efficiently perform multiple modification operations.
- Specified by:
builderin interfacePersistentCollection<E extends @Nullable Object>
-
mutate
-
addAll
Returns the result of adding all elements of the specifiedelementscollection to this set.- Specified by:
addAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements of the specified
elementscollection added; or this instance if it already contains every element of the specified collection.
-
addAll
Returns the result of adding all elements of the specifiedelementsarray to this set.- Specified by:
addAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements of the specified
elementsarray added; or this instance if it already contains every element of the specified array.
-
addAll
Returns the result of adding all elements of the specifiedelementssequence to this set.- Specified by:
addAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements of the specified
elementssequence added; or this instance if it already contains every element of the specified sequence.
-
removeAll
Returns the result of removing all elements in this set that are also contained in the specifiedelementscollection.- Specified by:
removeAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements in this set that are also
contained in the specified
elementscollection removed; or this instance if no modifications were made in the result of this operation.
-
removeAll
Returns the result of removing all elements in this set that are also contained in the specifiedelementsarray.- Specified by:
removeAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements in this set that are also
contained in the specified
elementsarray removed; or this instance if no modifications were made in the result of this operation.
-
removeAll
Returns the result of removing all elements in this set that are also contained in the specifiedelementssequence.- Specified by:
removeAllin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements in this set that are also
contained in the specified
elementssequence removed; or this instance if no modifications were made in the result of this operation.
-
intersect
Returns all elements in this set that are also contained in the specifiedelementscollection.- Specified by:
intersectin interfacePersistentCollection<E extends @Nullable Object>- Returns:
- a new persistent set with elements in this set that are also
contained in the specified
elementscollection; or this instance if no modifications were made in the result of this operation.
-