androidx.core.util


Interfaces

Consumer

Compat version of java.util.function.Consumer

Function

Compat version of java.util.function.Function

Pools.Pool

Interface for managing a pool of objects.

Predicate

Compat version of java.util.function.Predicate

Supplier

Compat version of java.util.function.Supplier

Classes

AtomicFile

Static library support version of the framework's android.util.AtomicFile, a helper class for performing atomic operations on a file by writing to a new file and renaming it into the place of the original file after the write has successfully completed.

ObjectsCompat

This class consists of static utility methods for operating on objects.

Pair

Container to ease passing around a tuple of two objects.

PatternsCompat

Commonly used regular expression patterns.

Pools

Helper class for creating pools of objects.

Pools.SimplePool

Simple (non-synchronized) pool of objects.

Pools.SynchronizedPool

Synchronized pool of objects.

SizeFCompat

Immutable class for describing width and height dimensions in some arbitrary unit.

TypedValueCompat

Container for a dynamically typed data value.

Top-level functions summary

inline LruCache<K, V>
<K : Any, V : Any> lruCache(
    maxSize: Int,
    crossinline sizeOf: (key, value) -> Int,
    crossinline create: (key) -> V?,
    crossinline onEntryRemoved: (evicted: Boolean, key, oldValue, newValue?) -> Unit
)

Creates an LruCache with the given parameters.

Extension functions summary

inline infix Range<T>
@RequiresApi(value = 21)
<T : Comparable<T>> Range<T>.and(other: Range<T>)

Return the intersection of this range and other.

Consumer<T>

Returns a Consumer that will resume this Continuation when the result of an operation is accepted.

Consumer<T>
@RequiresApi(value = 24)
<T : Any?> Continuation<T>.asConsumer()

Returns a java.util.function.Consumer that will resume this Continuation when the result of an operation is accepted.

Runnable

Returns a Runnable that will resume this Continuation when an operation completes and the returned Runnable's Runnable.run method is called.

inline operator F
<F : Any?, S : Any?> Pair<F, S>.component1()

Returns the first component of the pair.

inline operator F
<F : Any?, S : Any?> Pair<F, S>.component1()

Returns the first component of the pair.

inline operator Int
@RequiresApi(value = 21)
Size.component1()

Returns "width", the first component of this Size.

inline operator Float
@RequiresApi(value = 21)
SizeF.component1()

Returns "width", the first component of this SizeF.

inline operator Float

Returns "width", the first component of this SizeFCompat.

inline operator S
<F : Any?, S : Any?> Pair<F, S>.component2()

Returns the second component of the pair.

inline operator S
<F : Any?, S : Any?> Pair<F, S>.component2()

Returns the second component of the pair.

inline operator Int
@RequiresApi(value = 21)
Size.component2()

Returns "height", the second component of this Size.

inline operator Float
@RequiresApi(value = 21)
SizeF.component2()

Returns "height", the second component of this SizeF.

inline operator Float

Returns "height", the second component of this SizeFCompat.

inline operator Boolean
<T : Any?> SparseArray<T>.contains(key: Int)

Returns true if the collection contains key.

inline operator Boolean

Returns true if the collection contains key.

inline operator Boolean

Returns true if the collection contains key.

inline operator Boolean

Returns true if the collection contains key.

inline operator Boolean
<T : Any?> LongSparseArray<T>.contains(key: Long)

Returns true if the collection contains key.

inline Boolean
<T : Any?> SparseArray<T>.containsKey(key: Int)

Returns true if the collection contains key.

inline Boolean

Returns true if the collection contains key.

inline Boolean

Returns true if the collection contains key.

inline Boolean

Returns true if the collection contains key.

inline Boolean
<T : Any?> LongSparseArray<T>.containsKey(key: Long)

Returns true if the collection contains key.

inline Boolean

Returns true if the collection contains value.

inline Boolean

Returns true if the collection contains value.

inline Boolean

Returns true if the collection contains value.

inline Boolean
<T : Any?> LongSparseArray<T>.containsValue(value: T)

Returns true if the collection contains value.

inline Boolean
<T : Any?> SparseArray<T>.containsValue(value: T)

Returns true if the collection contains value.

inline Unit
<T : Any?> LongSparseArray<T>.forEach(action: (key: Long, value) -> Unit)

Performs the given action for each key/value entry.

inline Unit
<T : Any?> SparseArray<T>.forEach(action: (key: Int, value) -> Unit)

Performs the given action for each key/value entry.

inline Unit
SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit)

Performs the given action for each key/value entry.

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

Performs the given action for each key/value entry.

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

Performs the given action for each key/value entry.

inline Boolean
SparseBooleanArray.getOrDefault(key: Int, defaultValue: Boolean)

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

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

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

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

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

inline T
<T : Any?> SparseArray<T>.getOrDefault(key: Int, defaultValue: T)

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

inline T
<T : Any?> LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

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

inline T
<T : Any?> SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T)

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

inline Boolean
SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean)

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

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

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

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

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

inline T
<T : Any?> LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

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

inline Boolean

Return true when the collection contains no elements.

inline Boolean
<T : Any?> SparseArray<T>.isEmpty()

Return true when the collection contains no elements.

inline Boolean

Return true when the collection contains no elements.

inline Boolean

Return true when the collection contains no elements.

inline Boolean

Return true when the collection contains no elements.

inline Boolean

Return true when the collection contains elements.

inline Boolean
<T : Any?> SparseArray<T>.isNotEmpty()

Return true when the collection contains elements.

inline Boolean

Return true when the collection contains elements.

inline Boolean

Return true when the collection contains elements.

inline Boolean

Return true when the collection contains elements.

LongIterator

Return an iterator over the collection's keys.

IntIterator

Return an iterator over the collection's keys.

IntIterator

Return an iterator over the collection's keys.

IntIterator

Return an iterator over the collection's keys.

IntIterator

Return an iterator over the collection's keys.

operator LongSparseArray<T>
<T : Any?> LongSparseArray<T>.plus(other: LongSparseArray<T>)

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

inline operator Range<T>
@RequiresApi(value = 21)
<T : Comparable<T>> Range<T>.plus(other: Range<T>)

Return the smallest range that includes this and other.

operator SparseArray<T>
<T : Any?> SparseArray<T>.plus(other: SparseArray<T>)

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

operator SparseBooleanArray

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

operator SparseIntArray

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

operator SparseLongArray

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

inline operator Range<T>
@RequiresApi(value = 21)
<T : Comparable<T>> Range<T>.plus(value: T)

Return the smallest range that includes this and value.

Unit
<T : Any?> LongSparseArray<T>.putAll(other: LongSparseArray<T>)

Update this collection by adding or replacing entries from other.

Unit
<T : Any?> SparseArray<T>.putAll(other: SparseArray<T>)

Update this collection by adding or replacing entries from other.

Unit

Update this collection by adding or replacing entries from other.

Unit

Update this collection by adding or replacing entries from other.

Unit

Update this collection by adding or replacing entries from other.

inline infix Range<T>
@RequiresApi(value = 21)
<T : Comparable<T>> T.rangeTo(that: T)

Creates a range from this Comparable value to that.

inline ByteArray

Gets the entire content of this file as a byte array.

String

Gets the entire content of this file as a String using UTF-8 or specified charset.

Boolean

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

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

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

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

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

Boolean
<T : Any?> SparseArray<T>.remove(key: Int, value: T)

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

Boolean
<T : Any?> LongSparseArray<T>.remove(key: Long, value: T)

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

inline operator Unit

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

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

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

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

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

inline operator Unit
<T : Any?> SparseArray<T>.set(key: Int, value: T)

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

inline operator Unit
<T : Any?> LongSparseArray<T>.set(key: Long, value: T)

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

inline Pair<F, S>
<F : Any?, S : Any?> Pair<F, S>.toAndroidPair()

Returns this Kotlin Pair as an Android Pair.

inline Pair<F, S>
<F : Any?, S : Any?> Pair<F, S>.toAndroidXPair()

Returns this Kotlin Pair as an AndroidX Pair.

ClosedRange<T>
@RequiresApi(value = 21)
<T : Comparable<T>> Range<T>.toClosedRange()

Returns this Range as a ClosedRange.

inline Half

Returns a Half instance representing given Short.

inline Half
@RequiresApi(value = 26)
Float.toHalf()

Returns a Half instance representing given Float.

inline Half
@RequiresApi(value = 26)
Double.toHalf()

Returns a Half instance representing given Double.

inline Half
@RequiresApi(value = 26)
String.toHalf()

Returns a Half instance representing given String.

inline Pair<F, S>
<F : Any?, S : Any?> Pair<F, S>.toKotlinPair()

Returns this AndroidX Pair as a Kotlin Pair.

inline Pair<F, S>
<F : Any?, S : Any?> Pair<F, S>.toKotlinPair()

Returns this Android Pair as a Kotlin Pair.

Range<T>
@RequiresApi(value = 21)
<T : Comparable<T>> ClosedRange<T>.toRange()

Returns this ClosedRange as a Range.

inline Unit

Perform the write operations inside block on this file.

Iterator<T>

Return an iterator over the collection's values.

Iterator<T>

Return an iterator over the collection's values.

BooleanIterator

Return an iterator over the collection's values.

IntIterator

Return an iterator over the collection's values.

LongIterator

Return an iterator over the collection's values.

Unit

Sets the content of this file as an array of bytes.

Unit
AtomicFile.writeText(text: String, charset: Charset)

Sets the content of this file as text encoded using UTF-8 or specified charset.

Extension properties summary

Int

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

Int

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

Int

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

Int

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

Int

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

Top-level functions

lruCache

inline fun <K : Any, V : Any> lruCache(
    maxSize: Int,
    crossinline sizeOf: (key, value) -> Int = { _, _ -> 1 },
    crossinline create: (key) -> V? = { null as V? },
    crossinline onEntryRemoved: (evicted: Boolean, key, oldValue, newValue?) -> Unit = { _, _, _, _ -> }
): LruCache<K, V>

Creates an LruCache with the given parameters.

Parameters
maxSize: Int

for caches that do not specify sizeOf, this is the maximum number of entries in the cache. For all other caches, this is the maximum sum of the sizes of the entries in this cache.

crossinline sizeOf: (key, value) -> Int = { _, _ -> 1 }

function that returns the size of the entry for key and value in user-defined units. The default implementation returns 1.

crossinline create: (key) -> V? = { null as V? }

a create called after a cache miss to compute a value for the corresponding key. Returns the computed value or null if no value can be computed. The default implementation returns null.

crossinline onEntryRemoved: (evicted: Boolean, key, oldValue, newValue?) -> Unit = { _, _, _, _ -> }

a function called for entries that have been evicted or removed.

Extension functions

@RequiresApi(value = 21)
inline infix fun <T : Comparable<T>> Range<T>.and(other: Range<T>): Range<T>

Return the intersection of this range and other.

Throws
kotlin.IllegalArgumentException

if this is disjoint from other.

asAndroidXConsumer

fun <T : Any?> Continuation<T>.asAndroidXConsumer(): Consumer<T>

Returns a Consumer that will resume this Continuation when the result of an operation is accepted.

Useful for writing suspend bindings to async Jetpack library methods that accept Consumer as a result callback for a one-time operation:

public suspend fun FancinessManager.query(
query: FancinessManager.Query
): FancinessManager.QueryResult = suspendCancellableCoroutine<QueryResult> { continuation ->

// Any Android API that supports cancellation should be configured to propagate
// coroutine cancellation as follows:
val canceller = CancellationSignal()
continuation.invokeOnCancellation { canceller.cancel() }

// Invoke the FancinessManager#queryAsync method as follows:
queryAsync(
query,
canceller,
// Use a direct executor to avoid extra dispatch. Resuming the continuation will
// handle getting to the right thread or pool via the ContinuationInterceptor.
Runnable::run,
continuation.asAndroidXConsumer()
)
}

asConsumer

@RequiresApi(value = 24)
fun <T : Any?> Continuation<T>.asConsumer(): Consumer<T>

Returns a java.util.function.Consumer that will resume this Continuation when the result of an operation is accepted.

Useful for writing suspend bindings to async methods that accept java.util.function.Consumer as a result callback for a one-time operation:

public suspend fun FancinessManager.query(
query: FancinessManager.Query
): FancinessManager.QueryResult = suspendCancellableCoroutine<QueryResult> { continuation ->

// Any Android API that supports cancellation should be configured to propagate
// coroutine cancellation as follows:
val canceller = CancellationSignal()
continuation.invokeOnCancellation { canceller.cancel() }

// Invoke the FancinessManager#queryAsync method as follows:
queryAsync(
query,
canceller,
// Use a direct executor to avoid extra dispatch. Resuming the continuation will
// handle getting to the right thread or pool via the ContinuationInterceptor.
Runnable::run,
continuation.asConsumer()
)
}

asRunnable

fun Continuation<Unit>.asRunnable(): Runnable

Returns a Runnable that will resume this Continuation when an operation completes and the returned Runnable's Runnable.run method is called.

Useful for writing suspend bindings to async Jetpack library methods that accept Runnable as a completion callback for a one-time operation:

public suspend fun FancinessManager.setFanciness(
fanciness: Float
): Unit = suspendCancellableCoroutine<Unit> { continuation ->

// Any Android API that supports cancellation should be configured to propagate
// coroutine cancellation as follows:
val canceller = CancellationSignal()
continuation.invokeOnCancellation { canceller.cancel() }

// Invoke the FancinessManager#setFanciness method as follows:
queryAsync(
fanciness,
canceller,
// Use a direct executor to avoid extra dispatch. Resuming the continuation will
// handle getting to the right thread or pool via the ContinuationInterceptor.
Runnable::run,
continuation.asRunnable()
)
}

component1

inline operator fun <F : Any?, S : Any?> Pair<F, S>.component1(): F

Returns the first component of the pair.

This method allows to use destructuring declarations when working with pairs, for example:

val (first, second) = myPair

component1

inline operator fun <F : Any?, S : Any?> Pair<F, S>.component1(): F

Returns the first component of the pair.

This method allows to use destructuring declarations when working with pairs, for example:

val (first, second) = myPair

component1

@RequiresApi(value = 21)
inline operator fun Size.component1(): Int

Returns "width", the first component of this Size.

This method allows to use destructuring declarations when working with sizes, for example:

val (w, h) = mySize

component1

@RequiresApi(value = 21)
inline operator fun SizeF.component1(): Float

Returns "width", the first component of this SizeF.

This method allows to use destructuring declarations when working with sizes, for example:

val (w, h) = mySize

component1

inline operator fun SizeFCompat.component1(): Float

Returns "width", the first component of this SizeFCompat.

This method allows to use destructuring declarations when working with sizes, for example:

val (w, h) = mySize

component2

inline operator fun <F : Any?, S : Any?> Pair<F, S>.component2(): S

Returns the second component of the pair.

This method allows to use destructuring declarations when working with pairs, for example:

val (first, second) = myPair

component2

inline operator fun <F : Any?, S : Any?> Pair<F, S>.component2(): S

Returns the second component of the pair.

This method allows to use destructuring declarations when working with pairs, for example:

val (first, second) = myPair

component2

@RequiresApi(value = 21)
inline operator fun Size.component2(): Int

Returns "height", the second component of this Size.

This method allows to use destructuring declarations when working with sizes, for example:

val (w, h) = mySize

component2

@RequiresApi(value = 21)
inline operator fun SizeF.component2(): Float

Returns "height", the second component of this SizeF.

This method allows to use destructuring declarations when working with sizes, for example:

val (w, h) = mySize

component2

inline operator fun SizeFCompat.component2(): Float

Returns "height", the second component of this SizeFCompat.

This method allows to use destructuring declarations when working with sizes, for example:

val (w, h) = mySize

contains

inline operator fun <T : Any?> SparseArray<T>.contains(key: Int): Boolean

Returns true if the collection contains key.

contains

inline operator fun SparseBooleanArray.contains(key: Int): Boolean

Returns true if the collection contains key.

contains

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

Returns true if the collection contains key.

contains

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

Returns true if the collection contains key.

contains

inline operator fun <T : Any?> LongSparseArray<T>.contains(key: Long): Boolean

Returns true if the collection contains key.

containsKey

inline fun <T : Any?> SparseArray<T>.containsKey(key: Int): Boolean

Returns true if the collection contains key.

containsKey

inline fun SparseBooleanArray.containsKey(key: Int): Boolean

Returns true if the collection contains key.

containsKey

inline fun SparseIntArray.containsKey(key: Int): Boolean

Returns true if the collection contains key.

containsKey

inline fun SparseLongArray.containsKey(key: Int): Boolean

Returns true if the collection contains key.

containsKey

inline fun <T : Any?> LongSparseArray<T>.containsKey(key: Long): Boolean

Returns true if the collection contains key.

containsValue

inline fun SparseBooleanArray.containsValue(value: Boolean): Boolean

Returns true if the collection contains value.

containsValue

inline fun SparseIntArray.containsValue(value: Int): Boolean

Returns true if the collection contains value.

containsValue

inline fun SparseLongArray.containsValue(value: Long): Boolean

Returns true if the collection contains value.

containsValue

inline fun <T : Any?> LongSparseArray<T>.containsValue(value: T): Boolean

Returns true if the collection contains value.

containsValue

inline fun <T : Any?> SparseArray<T>.containsValue(value: T): Boolean

Returns true if the collection contains value.

forEach

inline fun <T : Any?> LongSparseArray<T>.forEach(action: (key: Long, value) -> Unit): Unit

Performs the given action for each key/value entry.

forEach

inline fun <T : Any?> SparseArray<T>.forEach(action: (key: Int, value) -> Unit): Unit

Performs the given action for each key/value entry.

forEach

inline fun SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit): Unit

Performs the given action for each key/value entry.

forEach

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

Performs the given action for each key/value entry.

forEach

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

Performs the given action for each key/value entry.

getOrDefault

inline fun SparseBooleanArray.getOrDefault(key: Int, defaultValue: Boolean): Boolean

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

getOrDefault

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

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

getOrDefault

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

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

getOrDefault

inline fun <T : Any?> SparseArray<T>.getOrDefault(key: Int, defaultValue: T): T

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

getOrDefault

inline fun <T : Any?> LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T): T

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

getOrElse

inline fun <T : Any?> SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T): T

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

getOrElse

inline fun SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean): Boolean

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

getOrElse

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

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

getOrElse

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

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

getOrElse

inline fun <T : Any?> LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T): T

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

isEmpty

inline fun <T : Any?> LongSparseArray<T>.isEmpty(): Boolean

Return true when the collection contains no elements.

isEmpty

inline fun <T : Any?> SparseArray<T>.isEmpty(): Boolean

Return true when the collection contains no elements.

isEmpty

inline fun SparseBooleanArray.isEmpty(): Boolean

Return true when the collection contains no elements.

isEmpty

inline fun SparseIntArray.isEmpty(): Boolean

Return true when the collection contains no elements.

isEmpty

inline fun SparseLongArray.isEmpty(): Boolean

Return true when the collection contains no elements.

isNotEmpty

inline fun <T : Any?> LongSparseArray<T>.isNotEmpty(): Boolean

Return true when the collection contains elements.

isNotEmpty

inline fun <T : Any?> SparseArray<T>.isNotEmpty(): Boolean

Return true when the collection contains elements.

isNotEmpty

inline fun SparseBooleanArray.isNotEmpty(): Boolean

Return true when the collection contains elements.

isNotEmpty

inline fun SparseIntArray.isNotEmpty(): Boolean

Return true when the collection contains elements.

isNotEmpty

inline fun SparseLongArray.isNotEmpty(): Boolean

Return true when the collection contains elements.

keyIterator

fun <T : Any?> LongSparseArray<T>.keyIterator(): LongIterator

Return an iterator over the collection's keys.

keyIterator

fun <T : Any?> SparseArray<T>.keyIterator(): IntIterator

Return an iterator over the collection's keys.

keyIterator

fun SparseBooleanArray.keyIterator(): IntIterator

Return an iterator over the collection's keys.

keyIterator

fun SparseIntArray.keyIterator(): IntIterator

Return an iterator over the collection's keys.

keyIterator

fun SparseLongArray.keyIterator(): IntIterator

Return an iterator over the collection's keys.

plus

operator fun <T : Any?> LongSparseArray<T>.plus(other: LongSparseArray<T>): LongSparseArray<T>

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

@RequiresApi(value = 21)
inline operator fun <T : Comparable<T>> Range<T>.plus(other: Range<T>): Range<T>

Return the smallest range that includes this and other.

plus

operator fun <T : Any?> SparseArray<T>.plus(other: SparseArray<T>): SparseArray<T>

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

plus

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

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

plus

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

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

plus

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

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

@RequiresApi(value = 21)
inline operator fun <T : Comparable<T>> Range<T>.plus(value: T): Range<T>

Return the smallest range that includes this and value.

putAll

fun <T : Any?> LongSparseArray<T>.putAll(other: LongSparseArray<T>): Unit

Update this collection by adding or replacing entries from other.

putAll

fun <T : Any?> SparseArray<T>.putAll(other: SparseArray<T>): Unit

Update this collection by adding or replacing entries from other.

putAll

fun SparseBooleanArray.putAll(other: SparseBooleanArray): Unit

Update this 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.

putAll

fun SparseLongArray.putAll(other: SparseLongArray): Unit

Update this collection by adding or replacing entries from other.

@RequiresApi(value = 21)
inline infix fun <T : Comparable<T>> T.rangeTo(that: T): Range<T>

Creates a range from this Comparable value to that.

Throws
kotlin.IllegalArgumentException

if this value is comparatively smaller than that.

readBytes

inline fun AtomicFile.readBytes(): ByteArray

Gets the entire content of this file as a byte array.

This method is not recommended on huge files. It has an internal limitation of 2 GB file size.

readText

fun AtomicFile.readText(charset: Charset = Charsets.UTF_8): String

Gets the entire content of this file as a String using UTF-8 or specified charset.

This method is not recommended on huge files. It has an internal limitation of 2 GB file size.

remove

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

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

remove

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

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

remove

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

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

remove

fun <T : Any?> SparseArray<T>.remove(key: Int, value: T): Boolean

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

remove

fun <T : Any?> LongSparseArray<T>.remove(key: Long, value: T): Boolean

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

set

inline operator fun SparseBooleanArray.set(key: Int, value: Boolean): Unit

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

set

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

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

set

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

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

set

inline operator fun <T : Any?> SparseArray<T>.set(key: Int, value: T): Unit

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

set

inline operator fun <T : Any?> LongSparseArray<T>.set(key: Long, value: T): Unit

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

toAndroidPair

inline fun <F : Any?, S : Any?> Pair<F, S>.toAndroidPair(): Pair<F, S>

Returns this Kotlin Pair as an Android Pair.

toAndroidXPair

inline fun <F : Any?, S : Any?> Pair<F, S>.toAndroidXPair(): Pair<F, S>

Returns this Kotlin Pair as an AndroidX Pair.

toClosedRange

@RequiresApi(value = 21)
fun <T : Comparable<T>> Range<T>.toClosedRange(): ClosedRange<T>

Returns this Range as a ClosedRange.

toHalf

@RequiresApi(value = 26)
inline fun @HalfFloat Short.toHalf(): Half

Returns a Half instance representing given Short.

See also
valueOf

toHalf

@RequiresApi(value = 26)
inline fun Float.toHalf(): Half

Returns a Half instance representing given Float.

See also
valueOf

toHalf

@RequiresApi(value = 26)
inline fun Double.toHalf(): Half

Returns a Half instance representing given Double.

See also
valueOf

toHalf

@RequiresApi(value = 26)
inline fun String.toHalf(): Half

Returns a Half instance representing given String.

See also
valueOf

toKotlinPair

inline fun <F : Any?, S : Any?> Pair<F, S>.toKotlinPair(): Pair<F, S>

Returns this AndroidX Pair as a Kotlin Pair.

toKotlinPair

inline fun <F : Any?, S : Any?> Pair<F, S>.toKotlinPair(): Pair<F, S>

Returns this Android Pair as a Kotlin Pair.

@RequiresApi(value = 21)
fun <T : Comparable<T>> ClosedRange<T>.toRange(): Range<T>

Returns this ClosedRange as a Range.

tryWrite

inline fun AtomicFile.tryWrite(block: (out: FileOutputStream) -> Unit): Unit

Perform the write operations inside block on this file. If block throws an exception the write will be failed. Otherwise the write will be applied atomically to the file.

valueIterator

fun <T : Any?> LongSparseArray<T>.valueIterator(): Iterator<T>

Return an iterator over the collection's values.

valueIterator

fun <T : Any?> SparseArray<T>.valueIterator(): Iterator<T>

Return an iterator over the collection's values.

valueIterator

fun SparseBooleanArray.valueIterator(): BooleanIterator

Return an iterator over the collection's values.

valueIterator

fun SparseIntArray.valueIterator(): IntIterator

Return an iterator over the collection's values.

valueIterator

fun SparseLongArray.valueIterator(): LongIterator

Return an iterator over the collection's values.

writeBytes

fun AtomicFile.writeBytes(array: ByteArray): Unit

Sets the content of this file as an array of bytes.

writeText

fun AtomicFile.writeText(text: String, charset: Charset = Charsets.UTF_8): Unit

Sets the content of this file as text encoded using UTF-8 or specified charset. If this file exists, it becomes overwritten.

Extension properties

val LongSparseArray<T>.sizeInt

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

val SparseArray<T>.sizeInt

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

size

val SparseBooleanArray.sizeInt

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

size

val SparseIntArray.sizeInt

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

size

val SparseLongArray.sizeInt

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