# ArrayMap

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/ArrayMap.java+class:androidx.collection.ArrayMap) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- android

  ```
  class ArrayMap<K, V> : SimpleArrayMap<K!, V!>, (Mutable)Map<K!, V!>
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.collection.SimpleArrayMap](https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap)\<K!, V!\> ||
|   | ↳ | [androidx.collection.ArrayMap](https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap) |

*** ** * ** ***

ArrayMap is a generic key-\>value mapping data structure that is designed to be more memory efficient than a traditional `https://developer.android.com/reference/java/util/HashMap.html`, this implementation is a version of the platform's `android.util.ArrayMap` that can be used on older versions of the platform. It keeps its mappings in an array data structure -- an integer array of hash codes for each item, and an Object array of the key/value pairs. This allows it to avoid having to create an extra object for every entry put in to the map, and it also tries to control the growth of the size of these arrays more aggressively (since growing them only requires copying the entries in the array, not rebuilding a hash map).

If you don't need the standard Java container APIs provided here (iterators etc), consider using `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap` instead.

Note that this implementation is not intended to be appropriate for data structures that may contain large numbers of items. It is generally slower than a traditional HashMap, since lookups require a binary search and adds and removes require inserting and deleting entries in the array. For containers holding up to hundreds of items, the performance difference is not significant, less than 50%.

Because this container is intended to better balance memory use, unlike most other standard Java containers it will shrink its array as items are removed from it. Currently you have no control over this shrinking -- if you set a capacity and then remove an item, it may reduce the capacity to better match the current size. In the future an explicit call to set the capacity should turn off this aggressive shrinking behavior.

**NOTE:** Consider using `https://developer.android.com/reference/kotlin/androidx/collection/MutableScatterMap` instead of this class. `https://developer.android.com/reference/kotlin/androidx/collection/MutableScatterMap` also avoids creating an extra object per entry but offers overall better performance characteristics. If a `https://developer.android.com/reference/java/util/Map.html`-like interface is required, please see `https://developer.android.com/reference/kotlin/androidx/collection/ScatterMap#asMap()` and `https://developer.android.com/reference/kotlin/androidx/collection/MutableScatterMap#asMutableMap()`.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#ArrayMap()()` | android |
| `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#ArrayMap(int)(capacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Create a new ArrayMap with a given initial capacity. | android |
| `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#ArrayMap(androidx.collection.SimpleArrayMap)(map: https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap?)` Create a new ArrayMap with the mappings from the given ArrayMap. | android |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#containsAll(java.util.Collection<?>)(collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<*>)` Determine if the array map contains all of the keys in the given collection. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#containsKey(java.lang.Object)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` Check whether a key exists in the array. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#containsValue(java.lang.Object)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` Check whether a value exists in the array. | android |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/-mutable-entry/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/-entry/index.html<K!, V!>!>` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#entrySet()()` Return a `https://developer.android.com/reference/java/util/Set.html` for iterating over and interacting with all mappings in the array map. | android |
| `V!` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#get(java.lang.Object)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` Retrieve a value from the array. | android |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<K!>` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#keySet()()` Return a `https://developer.android.com/reference/java/util/Set.html` for iterating over and interacting with all keys in the array map. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#putAll(java.util.Map<? extends K,? extends V>)(map: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<K!, V!>)` Perform a `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#put(K,V)` of all key/value pairs in <var translate="no">map</var> | android |
| `V!` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#remove(java.lang.Object)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` Remove an existing key from the array map. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#removeAll(java.util.Collection<?>)(collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<*>)` Remove all keys in the array map that exist in the given collection. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#retainAll(java.util.Collection<?>)(collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<*>)` Remove all keys in the array map that do **not** exist in the given collection. | android |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<V!>` | `https://developer.android.com/reference/kotlin/androidx/collection/ArrayMap#values()()` Return a `https://developer.android.com/reference/java/util/Collection.html` for iterating over and interacting with all values in the array map. | android |

### Inherited functions

From [java.util.Map](https://developer.android.com/reference/java/util/Map.html) `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/clear.html()` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/compute.html(key: K!, remappingFunction: https://developer.android.com/reference/java/util/function/BiFunction.html<K!, V!, V!>!)` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/compute-if-absent.html(key: K!, mappingFunction: https://developer.android.com/reference/java/util/function/Function.html<K!, V!>!)` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/compute-if-present.html(key: K!, remappingFunction: https://developer.android.com/reference/java/util/function/BiFunction.html<K!, V!, V!>!)` android `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<K!, V!>!` `<K, V> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/copy-of.html(map: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<K!, V!>!)` android `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/-mutable-entry/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/-entry/index.html<K!, V!>!` `<K, V> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/entry.html(k: K!, v: V!)` android `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/equals.html(p: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/for-each.html(action: https://developer.android.com/reference/java/util/function/BiConsumer.html<K!, V!>!)` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/get-or-default.html(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, defaultValue: V!)` android `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/hash-code.html()` android `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/is-empty.html()` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/merge.html(key: K!, value: V!, remappingFunction: https://developer.android.com/reference/java/util/function/BiFunction.html<V!, V!, V!>!)` android `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<K!, V!>!` `<K, V> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/of.html()` android `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<K!, V!>!` `<K, V> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/of-entries.html(entries: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/-mutable-entry/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/-entry/index.html<K!, V!>!>!)` android `abstract V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/put.html(p: K!, p1: V!)` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/put-if-absent.html(key: K!, value: V!)` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/remove.html(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` android `V!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/replace.html(key: K!, value: V!)` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/replace.html(key: K!, oldValue: V!, newValue: V!)` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/replace-all.html(function: https://developer.android.com/reference/java/util/function/BiFunction.html<K!, V!, V!>!)` android `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/size.html()` android From [androidx.collection.SimpleArrayMap](https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#__restricted$indexOfValue(V)(value: V!)` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#clear()()`

Make the array map empty.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#ensureCapacity(int)(minimumCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Ensure the array map can hold at least `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#ensureCapacity(kotlin.Int)` items.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#equals(java.lang.Object)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

This implementation returns `false` if the object is not a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html` or `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap`, or if the maps have different sizes.
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#getOrDefault(java.lang.Object,V)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, defaultValue: V!)`

Retrieve a value from the array, or `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#getOrDefault(kotlin.Any,kotlin.Any)` if there is no mapping for the key.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#hashCode()()` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#indexOfKey(K)(key: K!)`

Returns the index of a key in the set.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#isEmpty()()`

Return `true` if the array map contains no items.
android `K!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#keyAt(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Return the key at the given index in the array.
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#put(K,V)(key: K!, value: V!)`

Add a new value to the array map.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#putAll(androidx.collection.SimpleArrayMap<? extends K,? extends V>)(map: https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap<K!, V!>!)`

Perform a `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#put(kotlin.Any,kotlin.Any)` of all key/value pairs in `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#putAll(androidx.collection.SimpleArrayMap)`
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#putIfAbsent(K,V)(key: K!, value: V!)`

Add a new value to the array map only if the key does not already have a value or it is mapped to `null`.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#remove(K,V)(key: K!, value: V!)`

Remove an existing key from the array map only if it is currently mapped to `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#remove(kotlin.Any,kotlin.Any)`.
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#removeAt(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Remove the key/value mapping at the given index.
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#replace(K,V)(key: K!, value: V!)`

Replace the mapping for `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#replace(kotlin.Any,kotlin.Any)` only if it is already mapped to a value.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#replace(K,V,V)(key: K!, oldValue: V!, newValue: V!)`

Replace the mapping for `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#replace(kotlin.Any,kotlin.Any,kotlin.Any)` only if it is already mapped to `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#replace(kotlin.Any,kotlin.Any,kotlin.Any)`.
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#setValueAt(int,V)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: V!)`

Set the value at a given index in the array.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#size()()`

Return the number of items in this array map.
android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#toString()()`

Returns a string representation of the object.
android `V!` `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#valueAt(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Return the value at the given index in the array.
android

## Public constructors

### ArrayMap

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
ArrayMap()
```

### ArrayMap

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
ArrayMap(capacity: Int)
```

Create a new ArrayMap with a given initial capacity.

### ArrayMap

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
ArrayMap(map: SimpleArrayMap?)
```

Create a new ArrayMap with the mappings from the given ArrayMap.

## Public functions

### containsAll

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun containsAll(collection: (Mutable)Collection<*>): Boolean
```

Determine if the array map contains all of the keys in the given collection.

| Parameters |
|---|---|
| `collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<*>` | The collection whose contents are to be checked against. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Returns true if this array map contains a key for every entry in <var translate="no">collection</var>, else returns false. |

### containsKey

android

```
fun containsKey(key: Any?): Boolean
```

Check whether a key exists in the array.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | The key to search for. \*\* This must be the same type as <var translate="no">K</var> \*\* |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Returns `true` if the key exists, else `false`. |

### containsValue

android

```
fun containsValue(value: Any?): Boolean
```

Check whether a value exists in the array. This requires a linear search through the entire array.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | The value to search for. \*\* This must be the same type as <var translate="no">V</var> \*\* |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Returns `true` if the value exists, else `false`. |

### entrySet

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun entrySet(): (Mutable)Set<(Mutable)Map.Entry<K!, V!>!>
```

Return a `https://developer.android.com/reference/java/util/Set.html` for iterating over and interacting with all mappings in the array map.

**Note:** this is a very inefficient way to access the array contents, it requires generating a number of temporary objects.

**Note:**
the semantics of this Set are subtly different than that of a `https://developer.android.com/reference/java/util/HashMap.html`: most important, the `https://developer.android.com/reference/java/util/Map.Entry.html` object returned by its iterator is a single object that exists for the entire iterator, so you can **not** hold on to it after calling `https://developer.android.com/reference/java/util/Iterator.html#next()`.

### get

android

```
fun get(key: Any?): V!
```

Retrieve a value from the array.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | The key of the value to retrieve. \*\* This must be the same type as <var translate="no">K</var> \*\* |

| Returns |
|---|---|
| `V!` | Returns the value associated with the given key, or `null` if there is no such key. |

### keySet

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun keySet(): (Mutable)Set<K!>
```

Return a `https://developer.android.com/reference/java/util/Set.html` for iterating over and interacting with all keys in the array map.

**Note:** this is a fairly inefficient way to access the array contents, it requires generating a number of temporary objects.

### putAll

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun putAll(map: (Mutable)Map<K!, V!>): Unit
```

Perform a `https://developer.android.com/reference/kotlin/androidx/collection/SimpleArrayMap#put(K,V)` of all key/value pairs in <var translate="no">map</var>

| Parameters |
|---|---|
| `map: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<K!, V!>` | The map whose contents are to be retrieved. |

### remove

android

```
fun remove(key: Any?): V!
```

Remove an existing key from the array map.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | The key of the mapping to remove. \*\* This must be the same type as <var translate="no">V</var> \*\* |

| Returns |
|---|---|
| `V!` | Returns the value that was stored under the key, or `null` if there was no such key. |

### removeAll

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun removeAll(collection: (Mutable)Collection<*>): Boolean
```

Remove all keys in the array map that exist in the given collection.

| Parameters |
|---|---|
| `collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<*>` | The collection whose contents are to be used to remove keys. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Returns true if any keys were removed from the array map, else false. |

### retainAll

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun retainAll(collection: (Mutable)Collection<*>): Boolean
```

Remove all keys in the array map that do **not** exist in the given collection.

| Parameters |
|---|---|
| `collection: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<*>` | The collection whose contents are to be used to determine which keys to keep. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Returns true if any keys were removed from the array map, else false. |

### values

android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/collection#1.0.0)

```
fun values(): (Mutable)Collection<V!>
```

Return a `https://developer.android.com/reference/java/util/Collection.html` for iterating over and interacting with all values in the array map.

**Note:** this is a fairly inefficient way to access the array contents, it requires generating a number of temporary objects.