Google 致力于为黑人社区推动种族平等。查看具体举措

SnapshotStateList

@Stable class SnapshotStateList<T> : MutableList<T>, StateObject
kotlin.Any
   ↳ androidx.compose.runtime.snapshots.SnapshotStateList

An implementation of MutableList that can be observed and snapshot. This is the result type created by androidx.compose.mutableStateListOf.

This class closely implements the same semantics as ArrayList.

Summary

Nested classes

This is an internal implementation class of SnapshotStateList.

Public constructors

An implementation of MutableList that can be observed and snapshot.

Public methods
Boolean
add(element: T)

Unit
add(index: Int, element: T)

Boolean
addAll(index: Int, elements: Collection<T>)

Boolean
addAll(elements: Collection<T>)

Unit

Boolean
contains(element: T)

Boolean
containsAll(elements: Collection<T>)

T
get(index: Int)

Int
indexOf(element: T)

Boolean

MutableIterator<T>

Int
lastIndexOf(element: T)

MutableListIterator<T>

MutableListIterator<T>
listIterator(index: Int)

Unit

Add a new state record to the beginning of a list.

Boolean
remove(element: T)

Boolean
removeAll(elements: Collection<T>)

T
removeAt(index: Int)

Unit
removeRange(fromIndex: Int, toIndex: Int)

Boolean
retainAll(elements: Collection<T>)

T
set(index: Int, element: T)

MutableList<T>
subList(fromIndex: Int, toIndex: Int)

Inherited functions
Inherited extension functions
From androidx.compose.ui.gesture.kotlin.collections.List
Boolean
List<PointerInputChange>.anyPointersInBounds(bounds: IntSize)

Utility method that determines if any pointers are currently in bounds.

From androidx.wear.complications.data.kotlin.collections.Collection
IntArray

Converts an array of ComplicationType to an array of integers with the corresponding wire types.

From androidx.compose.ui.util.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.