# SimpleArrayMap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
Summary:[Ctors](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#)  

# SimpleArrayMap

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
SimpleArrayMap
`  
`

extends Object


``


`

|---|------------------------------------------------|
| java.lang.Object                                  ||
| ↳ | android.support.v4.util.SimpleArrayMap\<K, V\> |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#)Known Direct Subclasses [ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)\<K, V\> |----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)\<K, V\> | ArrayMap is a generic key-\>value mapping data structure that is designed to be more memory efficient than a traditional[HashMap](https://developer.android.com/reference/java/util/HashMap), this implementation is a version of the platform's`android.util.ArrayMap`that can be used on older versions of the platform. | |

<br />

*** ** * ** ***

Base implementation of[ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)that doesn't include any standard Java container API interoperability. These features are generally heavier-weight ways to interact with the container, so discouraged, but they can be useful to make it easier to use as a drop-in replacement for HashMap. If you don't need them, this class can be preferrable since it doesn't bring in any of the implementation of those APIs, allowing that code to be stripped by ProGuard.

## Summary

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

|                                                                                                                                                                                                                                            ### Public methods                                                                                                                                                                                                                                            ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`    | ` `[clear](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#clear())`() ` Make the array map empty.                                                                                                                                                                                                                                                                                                                                                            |
| ` boolean` | ` `[containsKey](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#containsKey(java.lang.Object))`(Object key) ` Check whether a key exists in the array.                                                                                                                                                                                                                                                                                                       |
| ` boolean` | ` `[containsValue](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#containsValue(java.lang.Object))`(Object value) ` Check whether a value exists in the array.                                                                                                                                                                                                                                                                                               |
| ` void`    | ` `[ensureCapacity](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#ensureCapacity(int))`(int minimumCapacity) ` Ensure the array map can hold at least<var translate="no">minimumCapacity</var>items.                                                                                                                                                                                                                                                        |
| ` boolean` | ` `[equals](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#equals(java.lang.Object))`(Object object) ` <br /> This implementation returns false if the object is not a Map or SimpleArrayMap, or if the maps have different sizes.                                                                                                                                                                                                                           |
| ` V`       | ` `[get](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#get(java.lang.Object))`(Object key) ` Retrieve a value from the array.                                                                                                                                                                                                                                                                                                                               |
| ` int`     | ` `[hashCode](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#hashCode())`() ` <br />                                                                                                                                                                                                                                                                                                                                                                         |
| ` int`     | ` `[indexOfKey](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#indexOfKey(java.lang.Object))`(Object key) ` Returns the index of a key in the set.                                                                                                                                                                                                                                                                                                           |
| ` boolean` | ` `[isEmpty](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#isEmpty())`() ` Return true if the array map contains no items.                                                                                                                                                                                                                                                                                                                                  |
| ` K`       | ` `[keyAt](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#keyAt(int))`(int index) ` Return the key at the given index in the array.                                                                                                                                                                                                                                                                                                                          |
| ` V`       | ` `[put](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#put(K, V))`(K key, V value) ` Add a new value to the array map.                                                                                                                                                                                                                                                                                                                                      |
| ` void`    | ` `[putAll](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#putAll(android.support.v4.util.SimpleArrayMap<? extends K, ? extends V>))`(`[SimpleArrayMap](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap)`<? extends K, ? extends V> array) ` Perform a[put(Object, Object)](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#put(K, V))of all key/value pairs in<var translate="no">array</var> |
| ` V`       | ` `[remove](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#remove(java.lang.Object))`(Object key) ` Remove an existing key from the array map.                                                                                                                                                                                                                                                                                                               |
| ` V`       | ` `[removeAt](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#removeAt(int))`(int index) ` Remove the key/value mapping at the given index.                                                                                                                                                                                                                                                                                                                   |
| ` V`       | ` `[setValueAt](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#setValueAt(int, V))`(int index, V value) ` Set the value at a given index in the array.                                                                                                                                                                                                                                                                                                       |
| ` int`     | ` `[size](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#size())`() ` Return the number of items in this array map.                                                                                                                                                                                                                                                                                                                                          |
| ` String`  | ` `[toString](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#toString())`() ` <br /> This implementation composes a string by iterating over its mappings.                                                                                                                                                                                                                                                                                                   |
| ` V`       | ` `[valueAt](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#valueAt(int))`(int index) ` Return the value at the given index in the array.                                                                                                                                                                                                                                                                                                                    |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### SimpleArrayMap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
SimpleArrayMap ()
```

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

<br />

### SimpleArrayMap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
SimpleArrayMap (int capacity)
```

Create a new ArrayMap with a given initial capacity.

<br />

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

### SimpleArrayMap

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
SimpleArrayMap (SimpleArrayMap<K, V> map)
```

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

<br />

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

## Public methods

### clear

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void clear ()
```

Make the array map empty. All storage is released.

<br />

### containsKey

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

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

### equals

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

<br />

This implementation returns false if the object is not a Map or SimpleArrayMap, 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` <br /> |

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

### get

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

```
int hashCode ()
```

<br />

<br />

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

### indexOfKey

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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 /> |

### isEmpty

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean isEmpty ()
```

Return true if the array map contains no items.

<br />

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

### keyAt

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Return the key at the given index in the array.

<br />

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

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

### put

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.**Must not be null.** 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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Perform a[put(Object, Object)](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#put(K, V))of all key/value pairs in<var translate="no">array</var>

<br />

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

### remove

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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 /> |

### removeAt

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Remove the key/value mapping at the given index.

<br />

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

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

### setValueAt

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Set the value at a given index in the array.

<br />

|                                                                            Parameters                                                                             ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `index` | `int`: The desired index, must be between 0 and[size()](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap#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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int size ()
```

Return the number of items in this array map.

<br />

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

### toString

```
String toString ()
```

<br />

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      ||
|----------|--------|
| `String` | <br /> |

### valueAt

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Return the value at the given index in the array.

<br />

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

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

-

  ## Interfaces

  - [Pools.Pool](https://developer.android.com/reference/android/support/v4/util/Pools.Pool)
-

  ## Classes

  - [ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)
  - [ArraySet](https://developer.android.com/reference/android/support/v4/util/ArraySet)
  - [AtomicFile](https://developer.android.com/reference/android/support/v4/util/AtomicFile)
  - [CircularArray](https://developer.android.com/reference/android/support/v4/util/CircularArray)
  - [CircularIntArray](https://developer.android.com/reference/android/support/v4/util/CircularIntArray)
  - [LongSparseArray](https://developer.android.com/reference/android/support/v4/util/LongSparseArray)
  - [LruCache](https://developer.android.com/reference/android/support/v4/util/LruCache)
  - [ObjectsCompat](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat)
  - [Pair](https://developer.android.com/reference/android/support/v4/util/Pair)
  - [PatternsCompat](https://developer.android.com/reference/android/support/v4/util/PatternsCompat)
  - [Pools](https://developer.android.com/reference/android/support/v4/util/Pools)
  - [Pools.SimplePool](https://developer.android.com/reference/android/support/v4/util/Pools.SimplePool)
  - [Pools.SynchronizedPool](https://developer.android.com/reference/android/support/v4/util/Pools.SynchronizedPool)
  - [SimpleArrayMap](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap)
  - [SparseArrayCompat](https://developer.android.com/reference/android/support/v4/util/SparseArrayCompat)