Google berkomitmen untuk mendorong terwujudnya keadilan ras bagi komunitas Kulit Hitam. Lihat caranya.


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

ArrayMap is a generic key->value mapping data structure that is designed to be more memory efficient than a traditional 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. 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 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.


Public constructors

<init>(capacity: Int)

Create a new ArrayMap with a given initial capacity.

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

Public methods
open Boolean
containsAll(@NonNull collection: MutableCollection<*>)

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

open Unit
putAll(@NonNull from: Map<out K, V>)

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

open Boolean
removeAll(@NonNull collection: MutableCollection<*>)

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

open Boolean
retainAll(@NonNull collection: MutableCollection<*>)

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

Inherited functions