# LongSparseArrayKt

Added in 1.1.0

*** ** * ** ***


```
public final class LongSparseArrayKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final boolean` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).contains(kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, long key)` Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).contains(kotlin.Long)`. |
| `static final boolean` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).containsKey(kotlin.Long)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, long key )` Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).containsKey(kotlin.Long)`. |
| `static final boolean` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).containsValue(kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull T value )` Returns true if the collection contains `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).containsValue(kotlin.Any)`. |
| `static final void` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).forEach(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> 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/Long.html, @https://developer.android.com/reference/androidx/annotation/NonNull value, 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.LongSparseArray).forEach(kotlin.Function2)` for each key/value entry. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull T` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).getOrDefault(kotlin.Long,kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, long key, @https://developer.android.com/reference/androidx/annotation/NonNull T defaultValue )` Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrDefault(kotlin.Long,kotlin.Any)`, or `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrDefault(kotlin.Long,kotlin.Any)` when not present. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull T` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).getOrElse(kotlin.Long,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, long key, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> defaultValue )` Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrElse(kotlin.Long,kotlin.Function0)`, or from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrElse(kotlin.Long,kotlin.Function0)` when not present. |
| `static final int` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).getSize()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver)` Returns the number of key/value pairs in the collection. |
| `static final boolean` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).isEmpty()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver)` Return true when the collection contains no elements. |
| `static final boolean` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).isNotEmpty()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> 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/-long-iterator/index.html` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).keyIterator()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> 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/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).plus(android.util.LongSparseArray)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> other )` Creates a new collection by adding or replacing entries from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).plus(android.util.LongSparseArray)`. |
| `static final void` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).putAll(android.util.LongSparseArray)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> other )` Update this collection by adding or replacing entries from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).putAll(android.util.LongSparseArray)`. |
| `static final boolean` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).remove(kotlin.Long,kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, long key, @https://developer.android.com/reference/androidx/annotation/NonNull T value )` Removes the entry for `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).remove(kotlin.Long,kotlin.Any)` only if it is mapped to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).remove(kotlin.Long,kotlin.Any)`. |
| `static final void` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).set(kotlin.Long,kotlin.Any)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> receiver, long key, @https://developer.android.com/reference/androidx/annotation/NonNull T 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://developer.android.com/reference/java/util/Iterator.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/core/util/LongSparseArrayKt#(android.util.LongSparseArray).valueIterator()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/LongSparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> 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/LongSparseArray.kt+function:contains) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean <T extends Object> contains(@NonNull LongSparseArray<@NonNull T> receiver, long key)
```

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

### 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/LongSparseArray.kt+function:containsKey) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean <T extends Object> containsKey(
    @NonNull LongSparseArray<@NonNull T> receiver,
    long key
)
```

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

### 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/LongSparseArray.kt+function:containsValue) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean <T extends Object> containsValue(
    @NonNull LongSparseArray<@NonNull T> receiver,
    @NonNull T value
)
```

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

### 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/LongSparseArray.kt+function:forEach) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void <T extends Object> forEach(
    @NonNull LongSparseArray<@NonNull T> receiver,
    @NonNull Function2<@NonNull Long, @NonNull value, Unit> action
)
```

Performs the given `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).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/LongSparseArray.kt+function:getOrDefault) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull T <T extends Object> getOrDefault(
    @NonNull LongSparseArray<@NonNull T> receiver,
    long key,
    @NonNull T defaultValue
)
```

Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrDefault(kotlin.Long,kotlin.Any)`, or `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrDefault(kotlin.Long,kotlin.Any)` 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/LongSparseArray.kt+function:getOrElse) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull T <T extends Object> getOrElse(
    @NonNull LongSparseArray<@NonNull T> receiver,
    long key,
    @NonNull Function0<@NonNull T> defaultValue
)
```

Return the value corresponding to `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrElse(kotlin.Long,kotlin.Function0)`, or from `https://developer.android.com/reference/androidx/core/util/package-summary#(android.util.LongSparseArray).getOrElse(kotlin.Long,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/LongSparseArray.kt+symbol:size) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int <T extends Object> getSize(@NonNull LongSparseArray<@NonNull T> receiver)
```

Returns the number of key/value pairs 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/LongSparseArray.kt+function:isEmpty) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean <T extends Object> isEmpty(@NonNull LongSparseArray<@NonNull T> 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/LongSparseArray.kt+function:isNotEmpty) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean <T extends Object> isNotEmpty(@NonNull LongSparseArray<@NonNull T> 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/LongSparseArray.kt+function:keyIterator) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull LongIterator <T extends Object> keyIterator(@NonNull LongSparseArray<@NonNull T> 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/LongSparseArray.kt+function:plus) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull LongSparseArray<@NonNull T> <T extends Object> plus(
    @NonNull LongSparseArray<@NonNull T> receiver,
    @NonNull LongSparseArray<@NonNull T> other
)
```

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

### 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/LongSparseArray.kt+function:putAll) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void <T extends Object> putAll(
    @NonNull LongSparseArray<@NonNull T> receiver,
    @NonNull LongSparseArray<@NonNull T> other
)
```

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

### 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/LongSparseArray.kt+function:remove) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean <T extends Object> remove(
    @NonNull LongSparseArray<@NonNull T> receiver,
    long key,
    @NonNull T value
)
```

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

### 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/LongSparseArray.kt+function:set) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void <T extends Object> set(
    @NonNull LongSparseArray<@NonNull T> receiver,
    long key,
    @NonNull T 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/LongSparseArray.kt+function:valueIterator) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull Iterator<@NonNull T> <T extends Object> valueIterator(@NonNull LongSparseArray<@NonNull T> receiver)
```

Return an iterator over the collection's values.