# SparseLongArrayKt

Added in 1.1.0

*** ** * ** ***


```
public final class SparseLongArrayKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final boolean` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).contains(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, int key)` Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).contains(kotlin.Int)`. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).containsKey(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, int key)` Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).containsKey(kotlin.Int)`. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).containsValue(kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, long value)` Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).containsValue(kotlin.Long)`. |
| `static final void` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).forEach(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Long.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).forEach(kotlin.Function2)` for each key/value entry. |
| `static final long` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).getOrDefault(kotlin.Int,kotlin.Long)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, int key, long defaultValue )` Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrDefault(kotlin.Int,kotlin.Long)`, or `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrDefault(kotlin.Int,kotlin.Long)` when not present. |
| `static final long` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).getOrElse(kotlin.Int,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, int key, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Long.html> defaultValue )` Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrElse(kotlin.Int,kotlin.Function0)`, or from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrElse(kotlin.Int,kotlin.Function0)` when not present. |
| `static final int` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).getSize()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver)` Returns the number of key/value entries in the collection. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).isEmpty()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver)` Return true when the collection contains no elements. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).isNotEmpty()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver)` Return true when the collection contains elements. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-int-iterator/index.html` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).keyIterator()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver)` Return an iterator over the collection's keys. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).plus(android.util.SparseLongArray)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html other)` Creates a new collection by adding or replacing entries from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).plus(android.util.SparseLongArray)`. |
| `static final void` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).putAll(android.util.SparseLongArray)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html other)` Update this collection by adding or replacing entries from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).putAll(android.util.SparseLongArray)`. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).remove(kotlin.Int,kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, int key, long value)` Removes the entry for `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).remove(kotlin.Int,kotlin.Long)` only if it is set to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).remove(kotlin.Int,kotlin.Long)`. |
| `static final void` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).set(kotlin.Int,kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver, int key, long value)` Allows the use of the index operator for storing values in the collection. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-long-iterator/index.html` | `https://developer.android.com/reference/androidx/core/util/SparseLongArrayKt#(android.util.SparseLongArray).valueIterator()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseLongArray.html receiver)` Return an iterator over the collection's values. |

## Public methods

### contains

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:contains) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean contains(@NonNull SparseLongArray receiver, int key)
```

Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).contains(kotlin.Int)`.

### containsKey

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:containsKey) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean containsKey(@NonNull SparseLongArray receiver, int key)
```

Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).containsKey(kotlin.Int)`.

### containsValue

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:containsValue) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean containsValue(@NonNull SparseLongArray receiver, long value)
```

Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).containsValue(kotlin.Long)`.

### forEach

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:forEach) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void forEach(
    @NonNull SparseLongArray receiver,
    @NonNull Function2<@NonNull Integer, @NonNull Long, Unit> action
)
```

Performs the given `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).forEach(kotlin.Function2)` for each key/value entry.

### getOrDefault

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:getOrDefault) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final long getOrDefault(
    @NonNull SparseLongArray receiver,
    int key,
    long defaultValue
)
```

Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrDefault(kotlin.Int,kotlin.Long)`, or `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrDefault(kotlin.Int,kotlin.Long)` when not present.

### getOrElse

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:getOrElse) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final long getOrElse(
    @NonNull SparseLongArray receiver,
    int key,
    @NonNull Function0<@NonNull Long> defaultValue
)
```

Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrElse(kotlin.Int,kotlin.Function0)`, or from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).getOrElse(kotlin.Int,kotlin.Function0)` when not present.

### getSize

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+symbol:size) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getSize(@NonNull SparseLongArray receiver)
```

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

### isEmpty

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:isEmpty) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean isEmpty(@NonNull SparseLongArray receiver)
```

Return true when the collection contains no elements.

### isNotEmpty

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:isNotEmpty) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean isNotEmpty(@NonNull SparseLongArray receiver)
```

Return true when the collection contains elements.

### keyIterator

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:keyIterator) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull IntIterator keyIterator(@NonNull SparseLongArray receiver)
```

Return an iterator over the collection's keys.

### plus

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:plus) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull SparseLongArray plus(@NonNull SparseLongArray receiver, @NonNull SparseLongArray other)
```

Creates a new collection by adding or replacing entries from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).plus(android.util.SparseLongArray)`.

### putAll

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:putAll) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void putAll(@NonNull SparseLongArray receiver, @NonNull SparseLongArray other)
```

Update this collection by adding or replacing entries from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).putAll(android.util.SparseLongArray)`.

### remove

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:remove) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean remove(@NonNull SparseLongArray receiver, int key, long value)
```

Removes the entry for `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).remove(kotlin.Int,kotlin.Long)` only if it is set to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.SparseLongArray).remove(kotlin.Int,kotlin.Long)`.

### set

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:set) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void set(@NonNull SparseLongArray receiver, int key, long value)
```

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

### valueIterator

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/SparseLongArray.kt+function:valueIterator) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull LongIterator valueIterator(@NonNull SparseLongArray receiver)
```

Return an iterator over the collection's values.