Get started

PersistentCollection

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.

Type Parameters

E

the type of elements contained in the collection. The persistent collection is covariant on its element type.

Inheritors

Types

Link copied to clipboard
interface Builder<E> : MutableCollection<E>

A generic builder of the persistent collection. Builder exposes its modification operations through the MutableCollection interface.

Functions

Link copied to clipboard
open fun adding(element: E): PersistentCollection<E>

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.

Link copied to clipboard

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.

Link copied to clipboard

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

Link copied to clipboard

Returns an empty persistent collection.

Link copied to clipboard

Returns a new persistent set with elements in this collection that are also contained in the specified elements collection.

Link copied to clipboard
inline operator fun <E> PersistentCollection<E>.minus(element: E): PersistentCollection<E>

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.

operator fun <E> PersistentCollection<E>.minus(elements: Array<out E>): PersistentCollection<E>

Returns a new persistent collection containing all elements of this collection except the elements contained in the specified elements array, or this instance if there are no elements to remove.

Returns a new persistent collection containing all elements of this collection except the elements contained in the specified elements collection, or this instance if there are no elements to remove.

Returns a new persistent collection containing all elements of this collection except the elements contained in the specified elements sequence, or this instance if there are no elements to remove.

Link copied to clipboard
inline operator fun <E> PersistentCollection<E>.plus(element: E): PersistentCollection<E>

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.

operator fun <E> PersistentCollection<E>.plus(elements: Array<out E>): PersistentCollection<E>

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.

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.

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.

Link copied to clipboard
open fun removing(element: E): PersistentCollection<E>

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.

Link copied to clipboard
open fun removingAll(predicate: (E) -> Boolean): PersistentCollection<E>

Returns a new persistent collection with elements matching the specified predicate removed, or this instance if no elements match the predicate.

Returns a new persistent collection containing all elements of this collection except the elements contained in the specified elements collection, or this instance if there are no elements to remove.

Link copied to clipboard

Returns a new persistent collection with elements in this collection that are also contained in the specified elements collection, or this instance if no modifications were made in the result of this operation.