Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/util/ArrayMap#pubctors) \| [Methods](https://developer.android.com/reference/android/util/ArrayMap#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/util/ArrayMap#inhmethods)

# ArrayMap

*** ** * ** ***


`
public

final

class
ArrayMap
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/util/Map<K, V>


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.util.ArrayMap\<K, V\> |

<br />

*** ** * ** ***

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`.
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).

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.

This structure is **NOT** thread-safe.

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/util/ArrayMap#ArrayMap()() ` Create a new empty ArrayMap. |
| ` https://developer.android.com/reference/android/util/ArrayMap#ArrayMap(android.util.ArrayMap<K,V>)(https://developer.android.com/reference/android/util/ArrayMap<K, V> map) ` Create a new ArrayMap with the mappings from the given ArrayMap. |
| ` https://developer.android.com/reference/android/util/ArrayMap#ArrayMap(int)(int capacity) ` Create a new ArrayMap with a given initial capacity. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/util/ArrayMap#clear()() ` Make the array map empty. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#containsAll(java.util.Collection<?>)(https://developer.android.com/reference/java/util/Collection<?> collection) ` Determine if the array map contains all of the keys in the given collection. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#containsKey(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key) ` Check whether a key exists in the array. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#containsValue(java.lang.Object)(https://developer.android.com/reference/java/lang/Object value) ` Check whether a value exists in the array. |
| ` void` | ` https://developer.android.com/reference/android/util/ArrayMap#ensureCapacity(int)(int minimumCapacity) ` Ensure the array map can hold at least <var translate="no">minimumCapacity</var> items. |
| ` https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/util/Map.Entry<K, V>>` | ` https://developer.android.com/reference/android/util/ArrayMap#entrySet()() ` Return a `https://developer.android.com/reference/java/util/Set` for iterating over and interacting with all mappings in the array map. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object object) ` Indicates whether some other object is "equal to" this one. This implementation returns false if the object is not a map, or if the maps have different sizes. |
| ` void` | ` https://developer.android.com/reference/android/util/ArrayMap#forEach(java.util.function.BiConsumer<?%20super%20K,?%20super%20V>)(https://developer.android.com/reference/java/util/function/BiConsumer<? super K, ? super V> action) ` Performs the given action for all elements in the stored order. |
| ` V` | ` https://developer.android.com/reference/android/util/ArrayMap#get(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key) ` Retrieve a value from the array. |
| ` int` | ` https://developer.android.com/reference/android/util/ArrayMap#hashCode()() ` Returns a hash code value for the object. |
| ` int` | ` https://developer.android.com/reference/android/util/ArrayMap#indexOfKey(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key) ` Returns the index of a key in the set. |
| ` int` | ` https://developer.android.com/reference/android/util/ArrayMap#indexOfValue(java.lang.Object)(https://developer.android.com/reference/java/lang/Object value) ` Returns an index for which `https://developer.android.com/reference/android/util/ArrayMap#valueAt(int)` would return the specified value, or a negative number if no keys map to the specified value. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#isEmpty()() ` Return true if the array map contains no items. |
| ` K` | ` https://developer.android.com/reference/android/util/ArrayMap#keyAt(int)(int index) ` Return the key at the given index in the array. |
| ` https://developer.android.com/reference/java/util/Set<K>` | ` https://developer.android.com/reference/android/util/ArrayMap#keySet()() ` Return a `https://developer.android.com/reference/java/util/Set` for iterating over and interacting with all keys in the array map. |
| ` V` | ` https://developer.android.com/reference/android/util/ArrayMap#put(K,%20V)(K key, V value) ` Add a new value to the array map. |
| ` void` | ` https://developer.android.com/reference/android/util/ArrayMap#putAll(android.util.ArrayMap<?%20extends%20K,?%20extends%20V>)(https://developer.android.com/reference/android/util/ArrayMap<? extends K, ? extends V> array) ` Perform a `https://developer.android.com/reference/android/util/ArrayMap#put(K,%20V)` of all key/value pairs in <var translate="no">array</var> |
| ` void` | ` https://developer.android.com/reference/android/util/ArrayMap#putAll(java.util.Map<?%20extends%20K,?%20extends%20V>)(https://developer.android.com/reference/java/util/Map<? extends K, ? extends V> map) ` Perform a `https://developer.android.com/reference/android/util/ArrayMap#put(K,%20V)` of all key/value pairs in <var translate="no">map</var> |
| ` V` | ` https://developer.android.com/reference/android/util/ArrayMap#remove(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key) ` Remove an existing key from the array map. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#removeAll(java.util.Collection<?>)(https://developer.android.com/reference/java/util/Collection<?> collection) ` Remove all keys in the array map that exist in the given collection. |
| ` V` | ` https://developer.android.com/reference/android/util/ArrayMap#removeAt(int)(int index) ` Remove the key/value mapping at the given index. |
| ` void` | ` https://developer.android.com/reference/android/util/ArrayMap#replaceAll(java.util.function.BiFunction<?%20super%20K,?%20super%20V,?%20extends%20V>)(https://developer.android.com/reference/java/util/function/BiFunction<? super K, ? super V, ? extends V> function) ` Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception. |
| ` boolean` | ` https://developer.android.com/reference/android/util/ArrayMap#retainAll(java.util.Collection<?>)(https://developer.android.com/reference/java/util/Collection<?> collection) ` Remove all keys in the array map that do **not** exist in the given collection. |
| ` V` | ` https://developer.android.com/reference/android/util/ArrayMap#setValueAt(int,%20V)(int index, V value) ` Set the value at a given index in the array. |
| ` int` | ` https://developer.android.com/reference/android/util/ArrayMap#size()() ` Return the number of items in this array map. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/util/ArrayMap#toString()() ` Returns a string representation of the object. This implementation composes a string by iterating over its mappings. |
| ` V` | ` https://developer.android.com/reference/android/util/ArrayMap#valueAt(int)(int index) ` Return the value at the given index in the array. |
| ` https://developer.android.com/reference/java/util/Collection<V>` | ` https://developer.android.com/reference/android/util/ArrayMap#values()() ` Return a `https://developer.android.com/reference/java/util/Collection` for iterating over and interacting with all values in the array map. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/java/util/Map

` `
abstract


void` `
https://developer.android.com/reference/java/util/Map#clear()()
`

Removes all of the mappings from this map (optional operation).


`

default


V` `
https://developer.android.com/reference/java/util/Map#compute(K,%20java.util.function.BiFunction<?%20super%20K,?%20super%20V,?%20extends%20V>)(K key, https://developer.android.com/reference/java/util/function/BiFunction<? super K, ? super V, ? extends V> remappingFunction)
`

Attempts to compute a mapping for the specified key and its current
mapped value, or `null` if there is no current mapping (optional
operation).


`

default


V` `
https://developer.android.com/reference/java/util/Map#computeIfAbsent(K,%20java.util.function.Function<?%20super%20K,?%20extends%20V>)(K key, https://developer.android.com/reference/java/util/function/Function<? super K, ? extends V> mappingFunction)
`

If the specified key is not already associated with a value (or is mapped
to `null`), attempts to compute its value using the given mapping
function and enters it into this map unless `null` (optional operation).


`

default


V` `
https://developer.android.com/reference/java/util/Map#computeIfPresent(K,%20java.util.function.BiFunction<?%20super%20K,?%20super%20V,?%20extends%20V>)(K key, https://developer.android.com/reference/java/util/function/BiFunction<? super K, ? super V, ? extends V> remappingFunction)
`

If the value for the specified key is present and non-null, attempts to
compute a new mapping given the key and its current mapped value
(optional operation).


`
abstract


boolean` `
https://developer.android.com/reference/java/util/Map#containsKey(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key)
`

Returns `true` if this map contains a mapping for the specified
key.


`
abstract


boolean` `
https://developer.android.com/reference/java/util/Map#containsValue(java.lang.Object)(https://developer.android.com/reference/java/lang/Object value)
`

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


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#copyOf(java.util.Map<?%20extends%20K,?%20extends%20V>)(https://developer.android.com/reference/java/util/Map<? extends K, ? extends V> map)
`

Returns an [unmodifiable Map](https://developer.android.com/reference/android/util/ArrayMap#unmodifiable) containing the entries
of the given Map.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map.Entry<K, V>` `
https://developer.android.com/reference/java/util/Map#entry(K,%20V)(K k, V v)
`

Returns an unmodifiable `https://developer.android.com/reference/java/util/Map.Entry` containing the given key and value.


`
abstract


https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/util/Map.Entry<K, V>>` `
https://developer.android.com/reference/java/util/Map#entrySet()()
`

Returns a `https://developer.android.com/reference/java/util/Set` view of the mappings contained in this map.


`
abstract


boolean` `
https://developer.android.com/reference/java/util/Map#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o)
`

Compares the specified object with this map for equality.


`

default


void` `
https://developer.android.com/reference/java/util/Map#forEach(java.util.function.BiConsumer<?%20super%20K,?%20super%20V>)(https://developer.android.com/reference/java/util/function/BiConsumer<? super K, ? super V> action)
`

Performs the given action for each entry in this map until all entries
have been processed or the action throws an exception.


`
abstract


V` `
https://developer.android.com/reference/java/util/Map#get(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key)
`

Returns the value to which the specified key is mapped,
or `null` if this map contains no mapping for the key.


`

default


V` `
https://developer.android.com/reference/java/util/Map#getOrDefault(java.lang.Object,%20V)(https://developer.android.com/reference/java/lang/Object key, V defaultValue)
`

Returns the value to which the specified key is mapped, or
`defaultValue` if this map contains no mapping for the key.


`
abstract


int` `
https://developer.android.com/reference/java/util/Map#hashCode()()
`

Returns the hash code value for this map.


`
abstract


boolean` `
https://developer.android.com/reference/java/util/Map#isEmpty()()
`

Returns `true` if this map contains no key-value mappings.


`
abstract


https://developer.android.com/reference/java/util/Set<K>` `
https://developer.android.com/reference/java/util/Map#keySet()()
`

Returns a `https://developer.android.com/reference/java/util/Set` view of the keys contained in this map.


`

default


V` `
https://developer.android.com/reference/java/util/Map#merge(K,%20V,%20java.util.function.BiFunction<?%20super%20V,?%20super%20V,?%20extends%20V>)(K key, V value, https://developer.android.com/reference/java/util/function/BiFunction<? super V, ? super V, ? extends V> remappingFunction)
`

If the specified key is not already associated with a value or is
associated with null, associates it with the given non-null value (optional
operation).


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
`

Returns an unmodifiable map containing five mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
`

Returns an unmodifiable map containing four mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V)(K k1, V v1)
`

Returns an unmodifiable map containing a single mapping.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8)
`

Returns an unmodifiable map containing eight mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2)
`

Returns an unmodifiable map containing two mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3)
`

Returns an unmodifiable map containing three mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of()()
`

Returns an unmodifiable map containing zero mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9)
`

Returns an unmodifiable map containing nine mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
`

Returns an unmodifiable map containing six mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)
`

Returns an unmodifiable map containing seven mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#of(K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V,%20K,%20V)(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10)
`

Returns an unmodifiable map containing ten mappings.


`


static

<K, V>
https://developer.android.com/reference/java/util/Map<K, V>` `
https://developer.android.com/reference/java/util/Map#ofEntries(java.util.Map.Entry<?%20extends%20K,?%20extends%20V>[])(https://developer.android.com/reference/java/util/Map.Entry<? extends K, ? extends V> entries)
`

Returns an unmodifiable map containing keys and values extracted from the given entries.


`
abstract


V` `
https://developer.android.com/reference/java/util/Map#put(K,%20V)(K key, V value)
`

Associates the specified value with the specified key in this map
(optional operation).


`
abstract


void` `
https://developer.android.com/reference/java/util/Map#putAll(java.util.Map<?%20extends%20K,?%20extends%20V>)(https://developer.android.com/reference/java/util/Map<? extends K, ? extends V> m)
`

Copies all of the mappings from the specified map to this map
(optional operation).


`

default


V` `
https://developer.android.com/reference/java/util/Map#putIfAbsent(K,%20V)(K key, V value)
`

If the specified key is not already associated with a value (or is mapped
to `null`) associates it with the given value and returns
`null`, else returns the current value (optional operation).


`

default


boolean` `
https://developer.android.com/reference/java/util/Map#remove(java.lang.Object,%20java.lang.Object)(https://developer.android.com/reference/java/lang/Object key, https://developer.android.com/reference/java/lang/Object value)
`

Removes the entry for the specified key only if it is currently
mapped to the specified value (optional operation).


`
abstract


V` `
https://developer.android.com/reference/java/util/Map#remove(java.lang.Object)(https://developer.android.com/reference/java/lang/Object key)
`

Removes the mapping for a key from this map if it is present
(optional operation).


`

default


boolean` `
https://developer.android.com/reference/java/util/Map#replace(K,%20V,%20V)(K key, V oldValue, V newValue)
`

Replaces the entry for the specified key only if currently
mapped to the specified value (optional operation).


`

default


V` `
https://developer.android.com/reference/java/util/Map#replace(K,%20V)(K key, V value)
`

Replaces the entry for the specified key only if it is
currently mapped to some value (optional operation).


`

default


void` `
https://developer.android.com/reference/java/util/Map#replaceAll(java.util.function.BiFunction<?%20super%20K,?%20super%20V,?%20extends%20V>)(https://developer.android.com/reference/java/util/function/BiFunction<? super K, ? super V, ? extends V> function)
`

Replaces each entry's value with the result of invoking the given
function on that entry until all entries have been processed or the
function throws an exception (optional operation).


`
abstract


int` `
https://developer.android.com/reference/java/util/Map#size()()
`

Returns the number of key-value mappings in this map.


`
abstract


https://developer.android.com/reference/java/util/Collection<V>` `
https://developer.android.com/reference/java/util/Map#values()()
`

Returns a `https://developer.android.com/reference/java/util/Collection` view of the values contained in this map.


## Public constructors

### ArrayMap

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ArrayMap ()
```

Create a new empty ArrayMap. The default capacity of an array map is 0, and
will grow once items are added to it.

<br />

### ArrayMap

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ArrayMap (ArrayMap<K, V> map)
```

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

<br />

| Parameters ||
|---|---|
| `map` | `ArrayMap` <br /> |

### ArrayMap

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ArrayMap (int capacity)
```

Create a new ArrayMap with a given initial capacity.

<br />

| Parameters ||
|---|---|
| `capacity` | `int` <br /> |

## Public methods

### clear

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void clear ()
```

Make the array map empty. All storage is released.

<br />

### containsAll

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsAll (Collection<?> collection)
```

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

<br />

| Parameters ||
|---|---|
| `collection` | `Collection`: The collection whose contents are to be checked against. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if this array map contains a key for every entry in <var translate="no">collection</var>, else returns false. <br /> |

### containsKey

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsKey (Object key)
```

Check whether a key exists in the array.

<br />

| Parameters ||
|---|---|
| `key` | `Object`: The key to search for. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if the key exists, else false. <br /> |

### containsValue

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsValue (Object value)
```

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

<br />

| Parameters ||
|---|---|
| `value` | `Object`: The value to search for. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if the value exists, else false. <br /> |

### ensureCapacity

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void ensureCapacity (int minimumCapacity)
```

Ensure the array map can hold at least <var translate="no">minimumCapacity</var>
items.

<br />

| Parameters ||
|---|---|
| `minimumCapacity` | `int` <br /> |

### entrySet

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Set<Entry<K, V>> entrySet ()
```

Return a `https://developer.android.com/reference/java/util/Set` 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 and allocates additional state
information associated with the container that will remain for the life of the container.

**Note:**
the semantics of this Set are subtly different than that of a `https://developer.android.com/reference/java/util/HashMap`: most important, the `https://developer.android.com/reference/java/util/Map.Entry` 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#next()`.

<br />

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/util/Map.Entry<K, V>>` | a set view of the mappings contained in this map <br /> |

### equals

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object object)
```

Indicates whether some other object is "equal to" this one.


The `equals` method implements an equivalence relation
on non-null object references:

- It is *reflexive*: for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is *symmetric*: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is *transitive*: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is *consistent*: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.


An equivalence relation partitions the elements it operates on
into *equivalence classes*; all the members of an
equivalence class are equal to each other. Members of an
equivalence class are substitutable for each other, at least
for some purposes.

This implementation returns false if the object is not a map, or
if the maps have different sizes. Otherwise, for each key in this map,
values of both maps are compared. If the values for any key are not
equal, the method returns false, otherwise it returns true.

<br />

| Parameters ||
|---|---|
| `object` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### forEach

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void forEach (BiConsumer<? super K, ? super V> action)
```

Performs the given action for all elements in the stored order. This implementation overrides
the default implementation to avoid iterating using the `https://developer.android.com/reference/android/util/ArrayMap#entrySet()` and iterates in
the key-value order consistent with `https://developer.android.com/reference/android/util/ArrayMap#keyAt(int)` and `https://developer.android.com/reference/android/util/ArrayMap#valueAt(int)`.

<br />

| Parameters ||
|---|---|
| `action` | `BiConsumer`: The action to be performed for each element <br /> |

### get

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public V get (Object key)
```

Retrieve a value from the array.

<br />

| Parameters ||
|---|---|
| `key` | `Object`: The key of the value to retrieve. <br /> |

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

### hashCode

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
`https://developer.android.com/reference/java/util/HashMap`.


The general contract of `hashCode` is:

- Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
- It is *not* required that if two objects are unequal according to the `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

<br />

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### indexOfKey

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int indexOfKey (Object key)
```

Returns the index of a key in the set.

<br />

| Parameters ||
|---|---|
| `key` | `Object`: The key to search for. <br /> |

| Returns ||
|---|---|
| `int` | Returns the index of the key if it exists, else a negative integer. <br /> |

### indexOfValue

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int indexOfValue (Object value)
```

Returns an index for which `https://developer.android.com/reference/android/util/ArrayMap#valueAt(int)` would return the
specified value, or a negative number if no keys map to the
specified value.
Beware that this is a linear search, unlike lookups by key,
and that multiple keys can map to the same value and this will
find only one of them.

<br />

| Parameters ||
|---|---|
| `value` | `Object` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### isEmpty

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isEmpty ()
```

Return true if the array map contains no items.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this map contains no key-value mappings <br /> |

### keyAt

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public K keyAt (int index)
```

Return the key at the given index in the array.

For indices outside of the range `0...size()-1`, the behavior is undefined for
apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#P` and earlier, and an
`https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` is thrown for apps targeting
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` and later.

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int`: The desired index, must be between 0 and `https://developer.android.com/reference/android/util/ArrayMap#size()`-1. <br /> |

| Returns ||
|---|---|
| `K` | Returns the key stored at the given index. <br /> |

### keySet

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Set<K> keySet ()
```

Return a `https://developer.android.com/reference/java/util/Set` 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 and allocates additional state
information associated with the container that will remain for the life of the container.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Set<K>` | a set view of the keys contained in this map <br /> |

### put

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public V put (K key, 
                V value)
```

Add a new value to the array map.

<br />

| Parameters ||
|---|---|
| `key` | `K`: The key under which to store the value. If this key already exists in the array, its value will be replaced. <br /> |
| `value` | `V`: The value to store for the given key. <br /> |

| Returns ||
|---|---|
| `V` | Returns the old value that was stored for the given key, or null if there was no such key. <br /> |

### putAll

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void putAll (ArrayMap<? extends K, ? extends V> array)
```

Perform a `https://developer.android.com/reference/android/util/ArrayMap#put(K,%20V)` of all key/value pairs in <var translate="no">array</var>

<br />

| Parameters ||
|---|---|
| `array` | `ArrayMap`: The array whose contents are to be retrieved. <br /> |

### putAll

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void putAll (Map<? extends K, ? extends V> map)
```

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

<br />

| Parameters ||
|---|---|
| `map` | `Map`: The map whose contents are to be retrieved. <br /> |

### remove

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public V remove (Object key)
```

Remove an existing key from the array map.

<br />

| Parameters ||
|---|---|
| `key` | `Object`: The key of the mapping to remove. <br /> |

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

### removeAll

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean removeAll (Collection<?> collection)
```

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

<br />

| Parameters ||
|---|---|
| `collection` | `Collection`: The collection whose contents are to be used to remove keys. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if any keys were removed from the array map, else false. <br /> |

### removeAt

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public V removeAt (int index)
```

Remove the key/value mapping at the given index.

For indices outside of the range `0...size()-1`, the behavior is undefined for
apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#P` and earlier, and an
`https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` is thrown for apps targeting
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` and later.

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int`: The desired index, must be between 0 and `https://developer.android.com/reference/android/util/ArrayMap#size()`-1. <br /> |

| Returns ||
|---|---|
| `V` | Returns the value that was stored at this index. <br /> |

### replaceAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void replaceAll (BiFunction<? super K, ? super V, ? extends V> function)
```

Replaces each entry's value with the result of invoking the given function on that entry
until all entries have been processed or the function throws an exception. Exceptions thrown
by the function are relayed to the caller. This implementation overrides
the default implementation to avoid iterating using the `https://developer.android.com/reference/android/util/ArrayMap#entrySet()` and iterates in
the key-value order consistent with `https://developer.android.com/reference/android/util/ArrayMap#keyAt(int)` and `https://developer.android.com/reference/android/util/ArrayMap#valueAt(int)`.

<br />

| Parameters ||
|---|---|
| `function` | `BiFunction`: The function to apply to each entry <br /> |

### retainAll

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean retainAll (Collection<?> collection)
```

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

<br />

| Parameters ||
|---|---|
| `collection` | `Collection`: The collection whose contents are to be used to determine which keys to keep. <br /> |

| Returns ||
|---|---|
| `boolean` | Returns true if any keys were removed from the array map, else false. <br /> |

### setValueAt

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public V setValueAt (int index, 
                V value)
```

Set the value at a given index in the array.

For indices outside of the range `0...size()-1`, the behavior is undefined for
apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#P` and earlier, and an
`https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` is thrown for apps targeting
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` and later.

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int`: The desired index, must be between 0 and `https://developer.android.com/reference/android/util/ArrayMap#size()`-1. <br /> |
| `value` | `V`: The new value to store at this index. <br /> |

| Returns ||
|---|---|
| `V` | Returns the previous value at the given index. <br /> |

### size

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int size ()
```

Return the number of items in this array map.

<br />

| Returns ||
|---|---|
| `int` | the number of key-value mappings in this map <br /> |

### toString

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

This implementation composes a string by iterating over its mappings. If
this map contains itself as a key or a value, the string "(this Map)"
will appear in its place.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### valueAt

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public V valueAt (int index)
```

Return the value at the given index in the array.

For indices outside of the range `0...size()-1`, the behavior is undefined for
apps targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#P` and earlier, and an
`https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` is thrown for apps targeting
`https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` and later.

<br />

<br />

| Parameters ||
|---|---|
| `index` | `int`: The desired index, must be between 0 and `https://developer.android.com/reference/android/util/ArrayMap#size()`-1. <br /> |

| Returns ||
|---|---|
| `V` | Returns the value stored at the given index. <br /> |

### values

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Collection<V> values ()
```

Return a `https://developer.android.com/reference/java/util/Collection` 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 and allocates additional state
information associated with the container that will remain for the life of the container.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<V>` | a collection view of the values contained in this map <br /> |