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

Extensions for android.util.SparseLongArray

contains

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

Returns true if the collection contains key.

containsKey

fun SparseLongArray.containsKey(key: Int): Boolean

Returns true if the collection contains key.

containsValue

fun SparseLongArray.containsValue(value: Long): Boolean

Returns true if the collection contains value.

forEach

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

Performs the given action for each key/value entry.

getOrDefault

fun SparseLongArray.getOrDefault(key: Int, defaultValue: Long): Long

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

getOrElse

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

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

isEmpty

fun SparseLongArray.isEmpty(): Boolean

Return true when the collection contains no elements.

isNotEmpty

fun SparseLongArray.isNotEmpty(): Boolean

Return true when the collection contains elements.

keyIterator

fun SparseLongArray.keyIterator(): IntIterator

Return an iterator over the collection's keys.

plus

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

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

putAll

fun SparseLongArray.putAll(other: SparseLongArray): Unit

Update this collection by adding or replacing entries from other.

remove

fun SparseLongArray.remove(key: Int, value: Long): Boolean

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

set

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

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

size

val SparseLongArray.size: Int

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

valueIterator

fun SparseLongArray.valueIterator(): LongIterator

Return an iterator over the collection's values.