<div class='sourceset sourceset-common'>Common</div>

```kotlin
interface Builder<K, V>: MutableMap<K, V>
```

A generic builder of the persistent map. Builder exposes its modification operations through the `MutableMap` interface.

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

Builder is backed by the same underlying data structure as the persistent map it was created from.
Thus, [builder](/jetpack-compose/androidx.compose.runtime/runtime/interfaces/PersistentMap.Builder) and [build](#build) methods take constant time passing the backing storage to the
new builder and persistent map instances, respectively.

The builder tracks which nodes in the structure are shared with the persistent map,
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](#build) is called the builder forgets about all owned nodes it had created.

## Functions

<h2 id="build">build</h2>

```kotlin
fun build(): PersistentMap<K, V>
```

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

This method can be called multiple times.

If operations applied on this builder have caused no modifications:
- on the first call it returns the same persistent map instance this builder was obtained from.
- on subsequent calls it returns the same previously returned persistent map instance.