Google 致力于为黑人社区推动种族平等。查看具体举措

androidx.collection

Classes

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.

ArraySet

ArraySet is a generic set data structure that is designed to be more memory efficient than a traditional java.util.HashSet.

CircularArray

CircularArray is a generic circular array data structure that provides O(1) random read, O(1) prepend and O(1) append.

CircularIntArray

CircularIntArray is a circular integer array data structure that provides O(1) random read, O(1) prepend and O(1) append.

LongSparseArray

SparseArray mapping longs to Objects.

LruCache

Static library version of android.util.LruCache.

SimpleArrayMap

Base implementation of ArrayMap that doesn't include any standard Java container API interoperability.

SparseArrayCompat

SparseArrays map integers to Objects.

Top-level functions summary

ArrayMap<K, V>

Returns an empty new ArrayMap.

ArrayMap<K, V>
arrayMapOf(vararg pairs: Pair<K, V>)

Returns a new ArrayMap with the specified contents, given as a list of pairs where the first component is the key and the second component is the value.

ArraySet<T>

Returns an empty new ArraySet.

ArraySet<T>
arraySetOf(vararg values: T)

Returns a new ArraySet with the specified contents.

LruCache<K, V>
lruCache(maxSize: Int, crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 }, crossinline create: (key: K) -> V? = { null as V? }, crossinline onEntryRemoved: (evicted: Boolean, key: K, oldValue: V, newValue: V?) -> Unit = { _, _, _, _ -> })

Creates an LruCache with the given parameters.

Extension functions summary

For LongSparseArray
operator Boolean

Returns true if the collection contains key.

Unit
LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit)

Performs the given action for each key/value entry.

T
LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

Return the value corresponding to key, or defaultValue when not present.

T
LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

Return the value corresponding to key, or from defaultValue when not present.

Boolean

Return true when the collection contains elements.

LongIterator

Return an iterator over the collection's keys.

operator LongSparseArray<T>

Creates a new collection by adding or replacing entries from other.

Boolean
LongSparseArray<T>.remove(key: Long, value: T)

Removes the entry for