RealmMap

interface RealmMap<K, V> : MutableMap<K, V>

A RealmMap is used to map keys to values. RealmMaps cannot contain duplicate keys and each key can be mapped to at most one value. RealmMaps cannot have null keys but can have null values.

Similarly to RealmList and RealmSet, RealmDictionary properties cannot be nullable.

Most importantly, RealmMaps can only have String keys and should not be used to define properties in RealmObjects. If you need to use a Map<String, V> or a dictionary-type data structure for your model you should use RealmDictionary.

Parameters

K

the type of the keys stored in this map

V

the type of the values stored in this map

Inheritors

Properties

Link copied to clipboard
abstract override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
Link copied to clipboard
abstract override val keys: MutableSet<K>
Link copied to clipboard
abstract val size: Int
Link copied to clipboard
abstract override val values: MutableCollection<V>

Functions

Link copied to clipboard
abstract fun asFlow(keyPaths: List<String>? = null): Flow<MapChange<K, V>>

Observes changes to the RealmMap. The Flow will emit InitialMap once subscribed, and then UpdatedMap on every change to the dictionary. The flow will continue running indefinitely until canceled or until the parent object is deleted.

Link copied to clipboard
abstract fun clear()
Link copied to clipboard
abstract fun containsKey(key: K): Boolean
Link copied to clipboard
abstract fun containsValue(value: V): Boolean
Link copied to clipboard
abstract operator fun get(key: K): V?
Link copied to clipboard
abstract fun isEmpty(): Boolean
Link copied to clipboard
abstract fun put(key: K, value: V): V?
Link copied to clipboard
abstract fun putAll(from: Map<out K, V>)
Link copied to clipboard
abstract fun remove(key: K): V?
Link copied to clipboard

Instantiates an unmanaged RealmDictionary containing all the elements of the receiver dictionary represented by a Map of String to T pairs.