core-ktx / androidx.util / android.util.LongSparseArray

Extensions for android.util.LongSparseArray

contains

operator fun <T> LongSparseArray<T>.contains(key: Long): Boolean

Returns true if the collection contains key.

containsKey

fun <T> LongSparseArray<T>.containsKey(key: Long): Boolean

Returns true if the collection contains key.

containsValue

fun <T> LongSparseArray<T>.containsValue(value: T): Boolean

Returns true if the collection contains value.

forEach

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

Performs the given action for each key/value entry.

getOrDefault

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

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

getOrElse

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

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

isEmpty

fun <T> LongSparseArray<T>.isEmpty(): Boolean

Return true when the collection contains no elements.

isNotEmpty

fun <T> LongSparseArray<T>.isNotEmpty(): Boolean

Return true when the collection contains elements.

keyIterator

fun <T> LongSparseArray<T>.keyIterator(): LongIterator

Return an iterator over the collection's keys.

plus

operator fun <T> LongSparseArray<T>.plus(other: LongSparseArray<T>): LongSparseArray<T>

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

putAll

fun <T> LongSparseArray<T>.putAll(other: LongSparseArray<T>): Unit

Update this collection by adding or replacing entries from other.

remove

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

Removes the entry for key only if it is mapped to value.

set

operator fun <T> LongSparseArray<T>.set(key: Long, value: T): Unit

Allows the use of the index operator for storing values in the collection.

size

val <T> LongSparseArray<T>.size: Int

Returns the number of key/value pairs in the collection.

valueIterator

fun <T> LongSparseArray<T>.valueIterator(): Iterator<T>

Return an iterator over the collection's values.