Android 12 Developer Preview is here! Try it out, and give us your feedback!

SimpleArrayMap

open class SimpleArrayMap<K : Any!, V : Any!>
kotlin.Any
   ↳ androidx.collection.SimpleArrayMap

Base implementation of 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

Create a new empty ArrayMap.

<init>(capacity: Int)

Create a new ArrayMap with a given initial capacity.

<init>(map: SimpleArrayMap<K, V>!)

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

Public methods
open Unit

Make the array map empty.

open Boolean
containsKey(@Nullable key: Any?)

Check whether a key exists in the array.

open Boolean
containsValue(value: Any!)

Check whether a value exists in the array.

open Unit
ensureCapacity(minimumCapacity: Int)

Ensure the array map can hold at least minimumCapacity items.

open Boolean
equals(other: Any?)

This implementation returns false if the object is not a Map or SimpleArrayMap, or if the maps have different sizes.

open V?
get(key: Any!)

Retrieve a value from the array.

open V
getOrDefault(key: Any!, defaultValue: V)

Retrieve a value from the array, or defaultValue if there is no mapping for the key.

open Int

open Int
indexOfKey(@Nullable key: Any?)

Returns the index of a key in the set.

open Boolean

Return true if the array map contains no items.

open K
keyAt(index: Int)

Return the key at the given index in the array.

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

Add a new value to the array map.

open Unit
putAll(@NonNull array: SimpleArrayMap<out K, out V>)

Perform a put(Object, Object) of all key/value pairs in array

open V?
putIfAbsent(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.

open V?
remove(key: Any!)

Remove an existing key from the array map.

open Boolean
remove(key: Any!, value: Any!)

Remove an existing key from the array map only if it is currently mapped to value.

open V
removeAt(index: Int)

Remove the key/value mapping at the given index.

open V?
replace(key: K, value: V)

Replace the mapping for key only if it is already mapped to a value.

open Boolean
replace(key: K, oldValue: V, newValue: V)

Replace the mapping for key only if it is already mapped to a value.

open V
setValueAt(index: Int, value: V)

Set the value at a given index in the array.

open Int

Return the number of items in this array map.

open String

This implementation composes a string by iterating over its mappings.

open V
valueAt(index: Int)

Return the value at the given index in the array.

Public constructors

<init>

SimpleArrayMap()

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

<init>

SimpleArrayMap(capacity: Int)

Create a new ArrayMap with a given initial capacity.

<init>

SimpleArrayMap(map: SimpleArrayMap<K, V>!)