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

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

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

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.

From androidx.compose.runtime.kotlin.collections.Collection
SnapshotStateList<T>

Create an instance of MutableList from a collection that is observerable and can be snapshot.

From androidx.compose.runtime.kotlin.collections.Iterable
SnapshotStateMap<K, V>

Create an instance of MutableMap<K, V> from a collection of pairs that is observable and can be snapshot.

Properties
SnapshotStateList.StateListStateRecord<T>

The first state record in a linked list of state records.

Int

Public constructors

<init>

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.

Public methods

add

fun add(element: T): Boolean

add

fun add(
    index: Int,
    element: T
): Unit

addAll

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

addAll

fun addAll(elements: Collection<T>): Boolean

clear

fun clear(): Unit

contains

fun contains(element: T): Boolean

containsAll

fun containsAll(elements: Collection<T>): Boolean

get

fun get(index: Int): T

indexOf

fun indexOf(element: T): Int

isEmpty

fun isEmpty(): Boolean

iterator

fun iterator(): MutableIterator<T>

lastIndexOf

fun lastIndexOf(element: T): Int

listIterator

fun listIterator(): MutableListIterator<T>

listIterator

fun listIterator(index: Int): MutableListIterator<T>

prependStateRecord

fun prependStateRecord(value: StateRecord): Unit

Add a new state record to the beginning of a list. After this call firstStateRecord should be value.

remove

fun remove(element: T): Boolean

removeAll

fun removeAll(elements: Collection<T>): Boolean

removeAt

fun removeAt(index: Int): T

removeRange

fun removeRange(
    fromIndex: Int,
    toIndex: Int
): Unit

retainAll

fun retainAll(elements: Collection<T>): Boolean

set

fun set(
    index: Int,
    element: T
): T

subList

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

Properties

firstStateRecord

var firstStateRecord: SnapshotStateList.StateListStateRecord<T>

The first state record in a linked list of state records.

size

val size: Int