Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.ui.util

Top-level functions summary

Boolean
isSurrogatePair(high: Char, low: Char)

Float
lerp(start: Float, stop: Float, fraction: Float)

Linearly interpolate between start and stop with fraction fraction between them.

Int
lerp(start: Int, stop: Int, fraction: Float)

Linearly interpolate between start and stop with fraction fraction between them.

Long
lerp(start: Long, stop: Long, fraction: Float)

Linearly interpolate between start and stop with fraction fraction between them.

Long
packFloats(val1: Float, val2: Float)

Packs two Float values into one Long value for use in inline classes.

Long
packInts(val1: Int, val2: Int)

Packs two Int values into one Long value for use in inline classes.

T
synchronized(lock: Any, block: () -> T)

kotlin.synchronized is deprecated, and the build fails if we use kotlin.synchronized along with the IR compiler.

T
trace(sectionName: String, block: () -> T)

Wrap the specified block in calls to Trace.beginSection (with the supplied sectionName) and Trace.endSection.

Float

Unpacks the first Float value in packFloats from its returned Long.

Float

Unpacks the second Float value in packFloats from its returned Long.

Int
unpackInt1(value: Long)

Unpacks the first Int value in packInts from its returned ULong.

Int
unpackInt2(value: Long)

Unpacks the second Int value in packInts from its returned ULong.

Extension functions summary

For java.lang.StringBuilder
actual StringBuilder

For kotlin.Any
actual Int

actual Any

For kotlin.Double
Double

For kotlin.Float
Float

actual String

For kotlin.Int
String

For kotlin.String
expect Int

expect Int

actual String
String.format(vararg args: Any?)

For kotlin.collections.List
Boolean
List<T>.fastAll(predicate: (T) -> Boolean)

Returns true if all elements match the given predicate.

Boolean
List<T>.fastAny(predicate: (T) -> Boolean)

Returns true if at least one element matches the given predicate.

T?
List<T>.fastFirstOrNull(predicate: (T) -> Boolean)

Returns the first value that predicate returns true for or null if nothing matches.

Unit
List<T>.fastForEach(action: (T) -> Unit)

Iterates through a List using the index and calls action for each item.

Unit
List<T>.fastForEachIndexed(action: (Int, T) -> Unit)

Iterates through a List using the index and calls action for each item.

List<R>
List<T>.fastMap(transform: (T) -> R)

Returns a list containing the results of applying the given transform function to each element in the original collection.

C
List<T>.fastMapTo(destination: C, transform: (T) -> R)

Applies the given transform function to each element of the original collection and appends the results to the given destination.

T?
List<T>.fastMaxBy(selector: (T) -> R)

Returns the first element yielding the largest value of the given function or null if there are no elements.

Int
List<T>.fastSumBy(selector: (T) -> Int)

Returns the sum of all values produced by selector function applied to each element in the list.

Top-level functions

isSurrogatePair

fun isSurrogatePair(
    high: Char,
    low: Char
): Boolean

lerp

fun lerp(
    start: Float,
    stop: Float,
    fraction: Float
): Float

Linearly interpolate between start and stop with fraction fraction between them.

lerp

fun lerp(
    start: Int,
    stop: Int,
    fraction: Float
): Int

Linearly interpolate between start and stop with fraction fraction between them.

lerp

fun lerp(
    start: Long,
    stop: Long,
    fraction: Float
): Long

Linearly interpolate between start and stop with fraction fraction between them.

packFloats

inline fun packFloats(
    val1: Float,
    val2: Float
): Long

Packs two Float values into one Long value for use in inline classes.

packInts

inline fun packInts(
    val1: Int,
    val2: Int
): Long

Packs two Int values into one Long value for use in inline classes.

synchronized

fun <T> synchronized(
    lock: Any,
    block: () -> T
): T

kotlin.synchronized is deprecated, and the build fails if we use kotlin.synchronized along with the IR compiler. As a workaround, we have this function here, which is in a module that doesn't use the IR Compiler.

trace

inline fun <T> trace(
    sectionName: String,
    block: () -> T
): T

Wrap the specified block in calls to Trace.beginSection (with the supplied sectionName) and Trace.endSection.

unpackFloat1

inline fun unpackFloat1(value: Long): Float

Unpacks the first Float value in packFloats from its returned Long.

unpackFloat2

inline fun unpackFloat2(value: Long): Float

Unpacks the second Float value in packFloats from its returned Long.

unpackInt1

inline fun unpackInt1(value: Long): Int

Unpacks the first Int value in packInts from its returned ULong.

unpackInt2

inline fun unpackInt2(value: Long): Int

Unpacks the second Int value in packInts from its returned ULong.

Extension functions

deleteAt

actual fun StringBuilder.deleteAt(index: Int): StringBuilder

fastAll

inline fun <T> List<T>.fastAll(predicate: (T) -> Boolean): Boolean

Returns true if all elements match the given predicate.

fastAny

inline fun <T> List<T>.fastAny(predicate: (T) -> Boolean): Boolean

Returns true if at least one element matches the given predicate.

fastFirstOrNull

inline fun <T> List<T>.fastFirstOrNull(predicate: (T) -> Boolean): T?

Returns the first value that predicate returns true for or null if nothing matches.

fastForEach

inline fun <T> 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.

fastForEachIndexed

inline fun <T> 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.

fastMap

inline fun <T, R> 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.

fastMapTo

inline fun <T, R, C : MutableCollection<in 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.

fastMaxBy

inline fun <T, 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.

fastSumBy

inline fun <T> List<T>.fastSumBy(selector: (T) -> Int): Int

Returns the sum of all values produced by selector function applied to each element in the list.

findFollowingBreak

expect fun String.findFollowingBreak(index: Int): Int

findPrecedingBreak

expect fun String.findPrecedingBreak(index: Int):