HashMap

actual typealias HashMap<K, V> = HashMap<K, V> (source)

Platform and version requirements: Kotlin 1.1, JVM

open actual class HashMap<K, V> : 
    AbstractMutableMap<K, V>,
    MutableMap<K, V>
(source)

Platform and version requirements: JS

Hash table based implementation of the MutableMap interface.

This implementation makes no guarantees regarding the order of enumeration of keys, values and entries collections.

Constructors

<init>

HashMap()
HashMap(initialCapacity: Int, loadFactor: Float = 0.0f)

Constructs an empty HashMap instance.

HashMap(initialCapacity: Int)
HashMap(original: Map<out K, V>)

Constructs an instance of HashMap filled with the contents of the specified original map.

Properties

entries

open actual val entries: MutableSet<MutableEntry<K, V>>

Returns a MutableSet of all key/value pairs in this map.

size

open actual val size: Int

Returns the number of key/value pairs in the map.

Inherited Properties

keys

open val keys: MutableSet<K>

Returns a MutableSet of all keys in this map.

values

open val values: MutableCollection<V>

Returns a MutableCollection of all values in this map. Note that this collection may contain duplicate values.

Functions

clear

open actual fun clear()

Removes all elements from this map.

containsKey

open actual fun containsKey(key: K): Boolean

Returns true if the map contains the specified key.

containsValue

open actual fun containsValue(value: V): Boolean

Returns true if the map maps one or more keys to the specified value.

createEntrySet

open fun createEntrySet(): MutableSet<MutableEntry<K, V>>

get

open operator actual fun get(key: K): V?

Returns the value corresponding to the given key, or null if such a key is not present in the map.

put

open actual fun put(key: K, value: V): V?

Associates the specified value with the specified key in the map.

remove

open actual fun remove(key: K): V?

Removes the specified key and its corresponding value from this map.

Inherited Functions

putAll

open fun putAll(from: Map<out K, V>)

Updates this map with key/value pairs from the specified map from.

fun isEmpty(): Boolean (source)

Overrides Map.isEmpty

Returns true if the map is empty (contains no elements), false otherwise.

fun putAll(from: Map<out K, V>) (source)

Overrides MutableMap.putAll

Updates this map with key/value pairs from the specified map from.

val keys: MutableSet<K> (source)

Overrides MutableMap.keys

Returns a MutableSet of all keys in this map.

Overrides MutableMap.values

Returns a MutableCollection of all values in this map. Note that this collection may contain duplicate values.