Interface PersistentCollection<E extends @Nullable Object>

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>

public interface PersistentCollection<E extends @Nullable Object> extends ImmutableCollection<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.

  • Method Details

    • add

      PersistentCollection<E> add(E element)
      Returns the result of adding the specified element to this collection.
      Returns:
      a new persistent collection with the specified element added; or this instance if this collection does not support duplicates and it already contains the element.
    • addAll

      PersistentCollection<E> addAll(Collection<? extends E> elements)
      Returns the result of adding all elements of the specified elements collection to this collection.
      Returns:
      a new persistent collection with elements of the specified elements collection added; or this instance if no modifications were made in the result of this operation.
    • remove

      PersistentCollection<E> remove(E element)
      Returns the result of removing a single appearance of the specified element from this collection.
      Returns:
      a new persistent collection with a single appearance of the specified element removed; or this instance if there is no such element in this collection.
    • removeAll

      PersistentCollection<E> removeAll(Collection<? extends E> elements)
      Returns the result of removing all elements in this collection that are also contained in the specified elements collection.
      Returns:
      a new persistent collection with elements in this collection that are also contained in the specified elements collection removed; or this instance if no modifications were made in the result of this operation.
    • removeAll

      PersistentCollection<E> removeAll(Predicate<? super E> predicate)
      Returns the result of removing all elements in this collection that match the specified predicate.
      Returns:
      a new persistent collection with elements matching the specified predicate removed; or this instance if no elements match the predicate.
    • retainAll

      PersistentCollection<E> retainAll(Collection<? extends E> elements)
      Returns all elements in this collection that are also contained in the specified elements collection.
      Returns:
      a new persistent set with elements in this set that are also contained in the specified elements collection; or this instance if no modifications were made in the result of this operation.
    • clear

      Returns an empty persistent collection.
    • builder

      Returns a new builder with the same contents as this collection.

      The builder can be used to efficiently perform multiple modification operations.

    • addAll

      default PersistentCollection<E> addAll(Iterable<? extends E> elements)
      Returns the result of adding all elements of the specified elements collection to this collection.
      Returns:
      a new persistent collection with elements of the specified elements collection added; or this instance if no modifications were made in the result of this operation.
    • addAll

      default PersistentCollection<E> addAll(E[] elements)
      Returns the result of adding all elements of the specified elements array to this collection.
      Returns:
      a new persistent collection with elements of the specified elements array added; or this instance if no modifications were made in the result of this operation.
    • addAll

      default PersistentCollection<E> addAll(Stream<? extends E> elements)
      Returns the result of adding all elements of the specified elements sequence to this collection.
      Returns:
      a new persistent collection with elements of the specified elements sequence added; or this instance if no modifications were made in the result of this operation.
    • removeAll

      default PersistentCollection<E> removeAll(Iterable<? extends E> elements)
      Returns the result of removing all elements in this collection that are also contained in the specified elements collection.
      Returns:
      a new persistent collection with elements in this collection that are also contained in the specified elements collection removed; or this instance if no modifications were made in the result of this operation.
    • removeAll

      default PersistentCollection<E> removeAll(E[] elements)
      Returns the result of removing all elements in this collection that are also contained in the specified elements array.
      Returns:
      a new persistent collection with elements in this collection that are also contained in the specified elements array removed; or this instance if no modifications were made in the result of this operation.
    • removeAll

      default PersistentCollection<E> removeAll(Stream<? extends E> elements)
      Returns the result of removing all elements in this collection that are also contained in the specified elements sequence.
      Returns:
      a new persistent collection with elements in this collection that are also contained in the specified elements sequence removed; or this instance if no modifications were made in the result of this operation.
    • intersect

      default PersistentSet<E> intersect(Iterable<? extends E> elements)
      Returns all elements in this collection that are also contained in the specified elements collection.
      Returns:
      a new persistent set with elements in this collection that are also contained in the specified elements collection