Get started

Builder

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

Builders are reusable, that is build method can be called multiple times with modifications between these calls. However, modifications applied do not affect previously built persistent collection instances.

Builder is backed by the same underlying data structure as the persistent collection it was created from. Thus, builder and build methods take constant time consisting of passing the backing storage to the new builder and persistent collection instances, respectively.

The builder tracks which nodes in the structure are shared with the persistent collection, and which are owned by it exclusively. It owns the nodes it copied during modification operations and avoids copying them on subsequent modifications.

When build is called the builder forgets about all owned nodes it had created.

Inheritors

Functions

Link copied to clipboard
abstract fun build(): PersistentCollection<E>

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