- Type Parameters:
E- the type of elements contained in the collection. The persistent collection is covariant on its element type.
- All Superinterfaces:
ImmutableCollection<E>, Iterable<E>
- All Known Subinterfaces:
PersistentList<E>, PersistentSet<E>
A generic persistent collection of elements that supports adding and removing elements.
Modification operations return new instances of the persistent collection with the modification applied.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePersistentCollection.Builder<E extends @Nullable Object>A generic builder of the persistent collection. -
Method Summary
Modifier and TypeMethodDescriptionReturns the result of adding the specifiedelementto this collection.default PersistentCollection<E> Returns the result of adding all elements of the specifiedelementsarray to this collection.default PersistentCollection<E> Returns the result of adding all elements of the specifiedelementscollection to this collection.addAll(Collection<? extends E> elements) Returns the result of adding all elements of the specifiedelementscollection to this collection.default PersistentCollection<E> Returns the result of adding all elements of the specifiedelementssequence to this collection.builder()Returns a new builder with the same contents as this collection.clear()Returns an empty persistent collection.default PersistentSet<E> Returns all elements in this collection that are also contained in the specifiedelementscollection.Returns the result of removing a single appearance of the specifiedelementfrom this collection.default PersistentCollection<E> Returns the result of removing all elements in this collection that are also contained in the specifiedelementsarray.default PersistentCollection<E> Returns the result of removing all elements in this collection that are also contained in the specifiedelementscollection.removeAll(Collection<? extends E> elements) Returns the result of removing all elements in this collection that are also contained in the specifiedelementscollection.Returns the result of removing all elements in this collection that match the specifiedpredicate.default PersistentCollection<E> Returns the result of removing all elements in this collection that are also contained in the specifiedelementssequence.retainAll(Collection<? extends E> elements) Returns all elements in this collection 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
-
add
Returns the result of adding the specifiedelementto this collection.- Returns:
- a new persistent collection with the specified
elementadded; or this instance if this collection does not support duplicates and it already contains the element.
-
addAll
Returns the result of adding all elements of the specifiedelementscollection to this collection.- Returns:
- a new persistent collection with elements of the specified
elementscollection added; or this instance if no modifications were made in the result of this operation.
-
remove
Returns the result of removing a single appearance of the specifiedelementfrom this collection.- Returns:
- a new persistent collection with a single appearance of the specified
elementremoved; or this instance if there is no such element in this collection.
-
removeAll
Returns the result of removing all elements in this collection that are also contained in the specifiedelementscollection.- Returns:
- a new persistent collection with elements in this collection 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 collection that match the specifiedpredicate.- Returns:
- a new persistent collection with elements matching the specified
predicateremoved; or this instance if no elements match the predicate.
-
retainAll
Returns all elements in this collection that are also contained in the specifiedelementscollection.- 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
PersistentCollection<E> clear()Returns an empty persistent collection. -
builder
PersistentCollection.Builder<E> builder()Returns a new builder with the same contents as this collection.
The builder can be used to efficiently perform multiple modification operations.
-
addAll
Returns the result of adding all elements of the specifiedelementscollection to this collection.- Returns:
- a new persistent collection with elements of the specified
elementscollection added; or this instance if no modifications were made in the result of this operation.
-
addAll
Returns the result of adding all elements of the specifiedelementsarray to this collection.- Returns:
- a new persistent collection with elements of the specified
elementsarray added; or this instance if no modifications were made in the result of this operation.
-
addAll
Returns the result of adding all elements of the specifiedelementssequence to this collection.- Returns:
- a new persistent collection with elements of the specified
elementssequence added; or this instance if no modifications were made in the result of this operation.
-
removeAll
Returns the result of removing all elements in this collection that are also contained in the specifiedelementscollection.- Returns:
- a new persistent collection with elements in this collection 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 collection that are also contained in the specifiedelementsarray.- Returns:
- a new persistent collection with elements in this collection 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 collection that are also contained in the specifiedelementssequence.- Returns:
- a new persistent collection with elements in this collection 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 collection that are also contained in the specifiedelementscollection.- Returns:
- a new persistent set with elements in this collection that are also
contained in the specified
elementscollection
-