SnapshotStateMap


An implementation of MutableMap that can be observed and snapshot. This is the result type created by androidx.compose.runtime.mutableStateMapOf.

This class closely implements the same semantics as HashMap.

Summary

Public constructors

<K : Any?, V : Any?> SnapshotStateMap()
Cmn

Public functions

open Unit
Cmn
open Boolean
containsKey(key: K)
Cmn
open Boolean
containsValue(value: V)
Cmn
open operator V?
get(key: K)
Cmn
open Boolean
Cmn
open Unit

Add a new state record to the beginning of a list.

Cmn
open V?
put(key: K, value: V)
Cmn
open Unit
putAll(from: Map<K, V>)
Cmn
open V?
remove(key: K)
Cmn
Map<K, V>

Returns an immutable map containing all key-value pairs from the original map.

Cmn
open String
Cmn

Public properties

open MutableSet<MutableMap.MutableEntry<K, V>>
Cmn
open StateRecord

The first state record in a linked list of state records.

Cmn
open MutableSet<K>
Cmn
open Int
Cmn
open MutableCollection<V>
Cmn

Inherited functions

From androidx.compose.runtime.snapshots.StateObject
open StateRecord?
mergeRecords(
    previous: StateRecord,
    current: StateRecord,
    applied: StateRecord
)

Produce a merged state based on the conflicting state changes.

Cmn

Public constructors

SnapshotStateMap

<K : Any?, V : Any?> SnapshotStateMap()

Public functions

clear

open fun clear(): Unit

containsKey

open fun containsKey(key: K): Boolean

containsValue

open fun containsValue(value: V): Boolean

get

open operator fun get(key: K): V?

isEmpty

open fun isEmpty(): Boolean

prependStateRecord

open fun prependStateRecord(value: StateRecord): Unit

Add a new state record to the beginning of a list. After this call firstStateRecord should be value.

put

open fun put(key: K, value: V): V?

putAll

open fun putAll(from: Map<K, V>): Unit

remove

open fun remove(key: K): V?

toMap

fun toMap(): Map<K, V>

Returns an immutable map containing all key-value pairs from the original map.

The content of the map returned will not change even if the content of the map is changed in the same snapshot. It also will be the same instance until the content is changed. It is not, however, guaranteed to be the same instance for the same content as adding and removing the same item from the this map might produce a different instance with the same content.

This operation is O(1) and does not involve a physically copying the map. It instead returns the underlying immutable map used internally to store the content of the map.

It is recommended to use toMap when using returning the value of this map from androidx.compose.runtime.snapshotFlow.

toString

open fun toString(): String

Public properties

entries

open val entriesMutableSet<MutableMap.MutableEntry<K, V>>

firstStateRecord

open val firstStateRecordStateRecord

The first state record in a linked list of state records.

keys

open val keysMutableSet<K>

size

open val sizeInt

values

open val valuesMutableCollection<V>