SnapshotStateMap
-
Cmn
class SnapshotStateMap<K : Any?, V : Any?> : StateObject, MutableMap
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.
| See also | |
|---|---|
mutableStateMapOf |
Summary
Public constructors |
|
|---|---|
<K : Any?, V : Any?> SnapshotStateMap() |
Cmn
|
Public functions |
||
|---|---|---|
open Unit |
clear() |
Cmn
|
open Boolean |
containsKey(key: K) |
Cmn
|
open Boolean |
containsValue(value: V) |
Cmn
|
open operator V? |
get(key: K) |
Cmn
|
open Boolean |
isEmpty() |
Cmn
|
open Unit |
prependStateRecord(value: StateRecord)Add a new state record to the beginning of a list. |
Cmn
|
open V? |
put(key: K, value: V) |
Cmn
|
open Unit |
Cmn
|
|
open V? |
remove(key: K) |
Cmn
|
Map<K, V> |
toMap()Returns an immutable map containing all key-value pairs from the original map. |
Cmn
|
open String |
toString() |
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 |
|||
|---|---|---|---|
|
Public constructors
Public functions
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.
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.
Public properties
firstStateRecord
open val firstStateRecord: StateRecord
The first state record in a linked list of state records.