{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
Float |
Linearly interpolate between |
Cmn
|
Int |
Linearly interpolate between |
Cmn
|
Long |
Linearly interpolate between |
Cmn
|
inline Long |
packFloats(val1: Float, val2: Float) Packs two Float values into one Long value for use in inline classes. |
Cmn
|
inline Long |
Packs two Int values into one Long value for use in inline classes. |
Cmn
|
inline T |
Wrap the specified |
android
|
inline Float |
unpackFloat1(value: Long) Unpacks the first Float value in |
Cmn
|
inline Float |
unpackFloat2(value: Long) Unpacks the second Float value in |
Cmn
|
inline Int |
unpackInt1(value: Long) Unpacks the first Int value in |
Cmn
|
inline Int |
unpackInt2(value: Long) Unpacks the second Int value in |
Cmn
|
inline Boolean |
Returns |
Cmn
|
inline Boolean |
Returns |
Cmn
|
inline T? |
<T : Any?> List<T>.fastFirstOrNull(predicate: (T) -> Boolean) Returns the first value that |
Cmn
|
inline Unit |
<T : Any?> List<T>.fastForEach(action: (T) -> Unit) Iterates through a |
Cmn
|
inline Unit |
<T : Any?> List<T>.fastForEachIndexed(action: (Int, T) -> Unit) Iterates through a |
Cmn
|
inline Unit |
<T : Any?> List<T>.fastForEachReversed(action: (T) -> Unit) Iterates through a |
Cmn
|
inline T? |
<T : Any?> List<T>.fastLastOrNull(predicate: (T) -> Boolean) Returns the last element matching the given |
Cmn
|
inline List<R> |
Returns a list containing the results of applying the given |
Cmn
|
inline C |
<T : Any?, R : Any?, C : MutableCollection<R>> List<T>.fastMapTo( Applies the given |
Cmn
|
inline T? |
<T : Any?, R : Comparable<R>> List<T>.fastMaxBy(selector: (T) -> R) Returns the first element yielding the largest value of the given function or |
Cmn
|
inline Int |
Returns the sum of all values produced by |
Cmn
|
fun lerp(start: Float, stop: Float, fraction: Float): Float
Linearly interpolate between start
and stop
with fraction
fraction between them.
fun lerp(start: Int, stop: Int, fraction: Float): Int
Linearly interpolate between start
and stop
with fraction
fraction between them.
fun lerp(start: Long, stop: Long, fraction: Float): Long
Linearly interpolate between start
and stop
with fraction
fraction between them.
inline fun packFloats(val1: Float, val2: Float): Long
Packs two Float values into one Long value for use in inline classes.
inline fun packInts(val1: Int, val2: Int): Long
Packs two Int values into one Long value for use in inline classes.
inline fun <T : Any?> trace(sectionName: String, block: () -> T): T
Wrap the specified block
in calls to Trace.beginSection
(with the supplied sectionName
) and Trace.endSection
.
inline fun unpackFloat1(value: Long): Float
Unpacks the first Float value in packFloats
from its returned Long.
inline fun unpackFloat2(value: Long): Float
Unpacks the second Float value in packFloats
from its returned Long.
inline fun unpackInt1(value: Long): Int
Unpacks the first Int value in packInts
from its returned ULong.
inline fun unpackInt2(value: Long): Int
Unpacks the second Int value in packInts
from its returned ULong.
inline fun <T : Any?> List<T>.fastAll(predicate: (T) -> Boolean): Boolean
Returns true
if all elements match the given predicate
.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastAny(predicate: (T) -> Boolean): Boolean
Returns true
if at least one element matches the given predicate
.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastFirstOrNull(predicate: (T) -> Boolean): T?
Returns the first value that predicate
returns true
for or null
if nothing matches.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastForEach(action: (T) -> Unit): Unit
Iterates through a List
using the index and calls action
for each item. This does not allocate an iterator like Iterable.forEach
.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastForEachIndexed(action: (Int, T) -> Unit): Unit
Iterates through a List
using the index and calls action
for each item. This does not allocate an iterator like Iterable.forEachIndexed
.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastForEachReversed(action: (T) -> Unit): Unit
Iterates through a List
in reverse order using the index and calls action
for each item. This does not allocate an iterator like Iterable.forEach
.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastLastOrNull(predicate: (T) -> Boolean): T?
Returns the last element matching the given predicate
, or null
if no such element was found.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?, R : Any?> List<T>.fastMap(transform: (T) -> R): List<R>
Returns a list containing the results of applying the given transform
function to each element in the original collection.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?, R : Any?, C : MutableCollection<R>> List<T>.fastMapTo(
destination: C,
transform: (T) -> R
): C
Applies the given transform
function to each element of the original collection and appends the results to the given destination
.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?, R : Comparable<R>> List<T>.fastMaxBy(selector: (T) -> R): T?
Returns the first element yielding the largest value of the given function or null
if there are no elements.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.
inline fun <T : Any?> List<T>.fastSumBy(selector: (T) -> Int): Int
Returns the sum of all values produced by selector
function applied to each element in the list.
Do not use for collections that come from public APIs, since they may not support random access in an efficient way, and this method may actually be a lot slower. Only use for collections that are created by code we control and are known to support random access.