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

Extensions for android.util.SparseIntArray

contains

operator fun SparseIntArray.contains(key: Int): Boolean

Returns true if the collection contains key.

containsKey

fun SparseIntArray.containsKey(key: Int): Boolean

Returns true if the collection contains key.

containsValue

fun SparseIntArray.containsValue(value: Int): Boolean

Returns true if the collection contains value.

forEach

fun SparseIntArray.forEach(action: (key: Int, value: Int) -> Unit): Unit

Performs the given action for each key/value entry.

getOrDefault

fun SparseIntArray.getOrDefault(key: Int, defaultValue: Int): Int

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

getOrElse

fun SparseIntArray.getOrElse(key: Int, defaultValue: () -> Int): Int

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

isEmpty

fun SparseIntArray.isEmpty(): Boolean

Return true when the collection contains no elements.

isNotEmpty

fun SparseIntArray.isNotEmpty(): Boolean

Return true when the collection contains elements.

keyIterator

fun SparseIntArray.keyIterator(): IntIterator

Return an iterator over the collection's keys.

plus

operator fun SparseIntArray.plus(other: SparseIntArray): SparseIntArray

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

putAll

fun SparseIntArray.putAll(other: SparseIntArray): Unit

Update this collection by adding or replacing entries from other.

remove

fun SparseIntArray.remove(key: Int, value: Int): Boolean

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

set

operator fun SparseIntArray.set(key: Int, value: Int): Unit

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

size

val SparseIntArray.size: Int

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

valueIterator

fun SparseIntArray.valueIterator(): IntIterator

Return an iterator over the collection's values.