Map

interface Map<K, out V>(source)

A read-only association from unique keys to values.

Different keys may share equal values. Nullable key and value types may store null. Read-only access does not guarantee immutability; aliases of HashMap observe its mutations. Iteration order and view behavior follow the concrete implementation's contract.

Type Parameters

K

key type.

V

value type.

See also

Inheritors

Types

Link copied to clipboard
interface Entry<out K, out V>

A key-value association exposed by a map.

Properties

Link copied to clipboard
abstract val entries: Set<Map.Entry<K, V>>

Read-only set of this map's key-value entries.

Link copied to clipboard
abstract val keys: Set<K>

Read-only set of this map's keys.

Link copied to clipboard
abstract val size: Int

Number of key-value associations in this map.

Link copied to clipboard
abstract val values: Collection<V>

Read-only collection of this map's values, retaining duplicates from different keys.

Functions

Link copied to clipboard
operator fun <K, V> Map<K, V>.contains(key: K): Boolean

Checks key membership using key in map syntax.

Link copied to clipboard
abstract fun containsKey(key: K): Boolean

Checks whether an association exists for key, including one whose value is null.

Link copied to clipboard
abstract fun containsValue(value: V): Boolean

Checks whether any stored value equals value.

Link copied to clipboard
abstract operator fun get(key: K): V?

Returns the value associated with key, or null when the key is absent.

Link copied to clipboard
abstract fun isEmpty(): Boolean

Checks whether this map contains no associations.

Link copied to clipboard
fun <K, V> Map<K, V>.isNotEmpty(): Boolean

Checks whether this map contains at least one association.

Link copied to clipboard
operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>>

Returns an iterator over this map's entries, enabling for ((key, value) in map).

Link copied to clipboard
abstract fun putAll(p0: Map<out K?, out V?>?)