MutableMultiMap

A mutable collection similar to a MutableMap except it allows multiple values to be associated with a single key. The associated values are not necessarily distinct (e.g., key foo may be associated with value bar multiple times).

Parameters

K

The type of elements used as keys

V

The type of elements used as values

Inheritors

Properties

Link copied to clipboard
abstract val entryValues: <Error class: unknown class><Map.Entry<K, V>>

Gets a Sequence of key-value pairs. A given key will appear multiple times in the sequence if it is associated with multiple values. This sequence lazily enumerates over keys and values in the multimap and may reflect changes which occurred after the iteration began.

Inherited properties

Link copied to clipboard
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<MutableList<V>>

Functions

Link copied to clipboard
abstract fun add(key: K, value: V): Boolean

Adds an association from the given key to the given value

abstract fun add(key: K, index: Int, value: V)

Adds an association from the given key to the given value, inserting it at the given index in the list of values already associated with the key.

Link copied to clipboard
open fun addAll(other: Map<K, List<V>>)

Adds all the key-value associations from another map into this one. This will append to the existing associations, not merge or deduplicate. This operation copies from the given values lists. Later changes to those lists do not affect this collection.

abstract fun addAll(key: K, values: Collection<V>): Boolean

Adds associations from the given key to the given values. This will append to the existing associations, not merge or deduplicate. This operation copies from the given values. Later changes to the collection do not affect this instance.

abstract fun addAll(key: K, index: Int, values: Collection<V>): Boolean

Adds associations from the given key to the given values, inserting them at the given index in the list of values already associated with the key. This operation copies from the given values. Later changes to the collection do not affect this instance.

Link copied to clipboard
open fun contains(key: K, value: V): Boolean

Checks if the specified value is present for the given key. Returns false if key is not present or if it is not associated with value.

Link copied to clipboard
open fun put(key: K, value: V): MutableList<V>?

Sets an association from the given key to the given value. This operation replaces any existing associations between key and other values.

Link copied to clipboard
abstract fun remove(key: K, value: V): Boolean

Removes the association from the given key to the given value.

Link copied to clipboard
abstract fun removeAll(key: K, values: Collection<V>): Boolean?

Removes the associations from the given key to the given values.

Link copied to clipboard
abstract fun removeAt(key: K, index: Int): V?

Removes the association from the given key to the value at the given index in the list of existing associations.

Link copied to clipboard
abstract fun retainAll(key: K, values: Collection<V>): Boolean?

Retains only associations from the given key to the given values. Any other associations from the given key to other values are removed.

Link copied to clipboard
open fun toMultiMap(): MultiMap<K, V>

Returns a new read-only multimap containing all the key-value associations from this multimap

Inherited functions

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: MutableList<V>): Boolean
Link copied to clipboard
abstract operator fun get(key: K): MutableList<V>?
Link copied to clipboard
abstract fun isEmpty(): Boolean
Link copied to clipboard
abstract fun put(key: K, value: MutableList<V>): MutableList<V>?
Link copied to clipboard
abstract fun putAll(from: Map<out K, MutableList<V>>)