🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

SnapshotStateMap

An implementation of MutableMap that can be observed and snapshot.

Source set: Common
public class SnapshotStateMap<K, V> : StateObject, MutableMap<K, V>

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.

Properties

firstStateRecord

Source set: Common
override var firstStateRecord: StateRecord =
        persistentHashMapOf<K, V>().let { map ->
            val snapshot = currentSnapshot()
            StateMapStateRecord(snapshot.snapshotId, map).also {
                if (snapshot !is GlobalSnapshot) {
                    it.next =
                        StateMapStateRecord(Snapshot.PreexistingSnapshotId.toSnapshotId(), map)
                }
            }
        }

size

Source set: Common
override val size: Int

entries

Source set: Common
override val entries: MutableSet<MutableMap.MutableEntry<K, V>> = SnapshotMapEntrySet(this)

keys

Source set: Common
override val keys: MutableSet<K> = SnapshotMapKeySet(this)

values

Source set: Common
override val values: MutableCollection<V> = SnapshotMapValueSet(this)

Functions

prependStateRecord

Source set: Common
override fun prependStateRecord(value: StateRecord)

toMap

Source set: Common
public 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.

containsKey

Source set: Common
override fun containsKey(key: K): Boolean

containsValue

Source set: Common
override fun containsValue(value: V): Boolean

get

Source set: Common
override fun get(key: K): V?

isEmpty

Source set: Common
override fun isEmpty(): Boolean

toString

Source set: Common
override fun toString(): String

clear

Source set: Common
override fun clear(): Unit

put

Source set: Common
override fun put(key: K, value: V): V?

putAll

Source set: Common
override fun putAll(from: Map<out K, V>): Unit

remove

Source set: Common
override fun remove(key: K): V?