ObserverMap
class ObserverMap<K : Any, V : Any>
kotlin.Any | |
↳ | androidx.compose.runtime.ObserverMap |
A map from a key to a set of values used for keeping the relation between some entities and a models changes of which this entities are observing.
Two main differences from a regular Map<K, Set>:
- Object.hashCode is not used, so the values can be mutable and change their hashCode value
- Objects are stored with WeakReference to prevent leaking them.
Summary
Public constructors | |
---|---|
<init>() A map from a key to a set of values used for keeping the relation between some entities and a models changes of which this entities are observing. |
Public methods | |
---|---|
Unit |
add(key: K, value: V) |
Unit |
clear() Clears all the keys and values from the map. |
Unit |
clearValues(predicate: (V) -> Boolean) Clears all the values that match the given predicate from all the sets. |
Boolean |
contains(key: K, value: V) Returns |
operator List<V> | |
List<V> |
getValueOf(key: K) |
Unit |
remove(key: K) Removes all the values associated with this key. |
Unit |
remove(key: K, value: V) |
Unit |
removeValue(value: V) Removes all values matching value. |
Public constructors
<init>
ObserverMap()
A map from a key to a set of values used for keeping the relation between some entities and a models changes of which this entities are observing.
Two main differences from a regular Map<K, Set>:
- Object.hashCode is not used, so the values can be mutable and change their hashCode value
- Objects are stored with WeakReference to prevent leaking them.
Public methods
clearValues
fun clearValues(predicate: (V) -> Boolean): Unit
Clears all the values that match the given predicate from all the sets.
contains
fun contains(
key: K,
value: V
): Boolean
Returns true
when the map contains the given key and value
get
operator fun get(keys: Iterable<K>): List<V>
Return | |
---|---|
a list of values associated with the provided | keys. |
remove
fun remove(key: K): Unit
Removes all the values associated with this key.
Return | |
---|---|
the list of values removed from the set as a result of this operation. |
remove
fun remove(
key: K,
value: V
): Unit