SparseArrayKt

Added in 1.3.0

public final class SparseArrayKt


Summary

Public methods

static final boolean
<T extends Object> contains(@NonNull SparseArrayCompat<@NonNull T> receiver, int key)

Returns true if the collection contains key.

static final void
<T extends Object> forEach(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    @NonNull Function2<@NonNull Integer, @NonNull value, Unit> action
)

Performs the given action for each key/value entry.

static final @NonNull T
<T extends Object> getOrDefault(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    int key,
    @NonNull T defaultValue
)

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

static final @NonNull T
<T extends Object> getOrElse(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    int key,
    @NonNull Function0<@NonNull T> defaultValue
)

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

static final int

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

static final boolean
<T extends Object> isNotEmpty(@NonNull SparseArrayCompat<@NonNull T> receiver)

Return true when the collection contains elements.

static final @NonNull IntIterator
<T extends Object> keyIterator(@NonNull SparseArrayCompat<@NonNull T> receiver)

Return an iterator over the collection's keys.

static final @NonNull SparseArrayCompat<@NonNull T>
<T extends Object> plus(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    @NonNull SparseArrayCompat<@NonNull T> other
)

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

static final void
<T extends Object> set(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    int key,
    @NonNull T value
)

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

static final @NonNull Iterator<@NonNull T>
<T extends Object> valueIterator(@NonNull SparseArrayCompat<@NonNull T> receiver)

Return an iterator over the collection's values.

Public methods

contains

public static final boolean <T extends Object> contains(@NonNull SparseArrayCompat<@NonNull T> receiver, int key)

Returns true if the collection contains key.

forEach

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

Performs the given action for each key/value entry.

getOrDefault

public static final @NonNull T <T extends Object> getOrDefault(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    int key,
    @NonNull T defaultValue
)

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

getOrElse

public static final @NonNull T <T extends Object> getOrElse(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    int key,
    @NonNull Function0<@NonNull T> defaultValue
)

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

public static final int getSize(@NonNull SparseArrayCompat<@NonNull T> receiver)

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

isNotEmpty

public static final boolean <T extends Object> isNotEmpty(@NonNull SparseArrayCompat<@NonNull T> receiver)

Return true when the collection contains elements.

keyIterator

public static final @NonNull IntIterator <T extends Object> keyIterator(@NonNull SparseArrayCompat<@NonNull T> receiver)

Return an iterator over the collection's keys.

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

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

public static final void <T extends Object> set(
    @NonNull SparseArrayCompat<@NonNull T> receiver,
    int key,
    @NonNull T value
)

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

valueIterator

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

Return an iterator over the collection's values.