# SnapshotStateList

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/snapshots/SnapshotStateList.+class:androidx.compose.runtime.snapshots.SnapshotStateList) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class SnapshotStateList<T : Any?> : StateObject, MutableList<T>, RandomAccess
  ```

*** ** * ** ***

An implementation of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html` that can be observed and snapshot. This is the result type created by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateListOf()`.

This class closely implements the same semantics as `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-array-list/index.html`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#mutableStateListOf()` |   |

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#SnapshotStateList()()` | Cmn android |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#add(kotlin.Any)(element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#add(kotlin.Int,kotlin.Any)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#addAll(kotlin.collections.Collection)(elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T>)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#addAll(kotlin.Int,kotlin.collections.Collection)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T>)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#clear()()` | Cmn android |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#contains(kotlin.Any)(element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#containsAll(kotlin.collections.Collection)(elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T>)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#describeContents()()` | android |
| `open operator T` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#get(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#indexOf(kotlin.Any)(element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#isEmpty()()` | Cmn android |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterator/index.html<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#iterator()()` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#lastIndexOf(kotlin.Any)(element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list-iterator/index.html<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#listIterator()()` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list-iterator/index.html<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#listIterator(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)(value: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord)` Add a new state record to the beginning of a list. | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#remove(kotlin.Any)(element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#removeAll(kotlin.collections.Collection)(elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T>)` | Cmn android |
| `open T` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#removeAt(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#removeRange(kotlin.Int,kotlin.Int)(fromIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, toIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#retainAll(kotlin.collections.Collection)(elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T>)` | Cmn android |
| `open operator T` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#set(kotlin.Int,kotlin.Any)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, element: T)` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#subList(kotlin.Int,kotlin.Int)(fromIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, toIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#toList()()` Return a list containing all the elements of this list. | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#toString()()` | android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#toString()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#writeToParcel(android.os.Parcel,kotlin.Int)(parcel: https://developer.android.com/reference/android/os/Parcel.html, flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | android |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#firstStateRecord()` The first state record in a linked list of state records. | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#size()` | Cmn android |

### Inherited functions

From [kotlin.collections.Collection](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html) `open https://developer.android.com/reference/java/util/stream/Stream.html<T>` `@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/parallel-stream.html()` android `open https://developer.android.com/reference/java/util/stream/Stream.html<T>` `@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/stream.html()` android `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<T>` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/to-array.html(generator: https://developer.android.com/reference/java/util/function/IntFunction.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<T>>)` android From [kotlin.collections.Iterable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/index.html) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/for-each.html(@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull action: https://developer.android.com/reference/java/util/function/Consumer.html<T>)` android From [kotlin.collections.List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html) `open T` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/get-first.html()` android `open T` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/get-last.html()` android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html<T>` `@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/reversed.html()` android `open https://developer.android.com/reference/java/util/Spliterator.html<T>` `@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/spliterator.html()` android From [kotlin.collections.MutableCollection](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/remove-if.html(@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull filter: https://developer.android.com/reference/java/util/function/Predicate.html<T>)` android From [kotlin.collections.MutableList](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/add-first.html(e: T)` android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/add-last.html(e: T)` android `open T` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/remove-first.html()` android `open T` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/remove-last.html()` android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/replace-all.html(@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNonNull operator: https://developer.android.com/reference/java/util/function/UnaryOperator.html<T>)` android `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/sort.html(@https://developer.android.com/reference/kotlin/androidx/annotation/RecentlyNullable c: https://developer.android.com/reference/java/util/Comparator.html<T>)` android From [androidx.compose.runtime.snapshots.StateObject](https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject) `open https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord?` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)(
previous: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord,
current: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord,
applied: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord
)`

Produce a merged state based on the conflicting state changes.
android `open https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord?` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)(
previous: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord,
current: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord,
applied: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord
)`

Produce a merged state based on the conflicting state changes.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord?` `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject#mergeRecords(androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord,androidx.compose.runtime.snapshots.StateRecord)(
previous: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord,
current: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord,
applied: https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateRecord
)`

Produce a merged state based on the conflicting state changes.
Cmn

## Public constructors

### SnapshotStateList

Cmn android

```
<T : Any?> SnapshotStateList()
```

## Public functions

### add

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun add(element: T): Boolean
```

### add

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

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

### addAll

Cmn android

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

### addAll

Cmn android

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

### clear

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun clear(): Unit
```

### contains

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open operator fun contains(element: T): Boolean
```

### containsAll

Cmn android

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

### describeContents

android Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.9.0)

```
open fun describeContents(): Int
```

### get

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open operator fun get(index: Int): T
```

### indexOf

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun indexOf(element: T): Int
```

### isEmpty

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun isEmpty(): Boolean
```

### iterator

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open operator fun iterator(): MutableIterator<T>
```

### lastIndexOf

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun lastIndexOf(element: T): Int
```

### listIterator

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun listIterator(): MutableListIterator<T>
```

### listIterator

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

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

### prependStateRecord

Cmn android

```
open fun prependStateRecord(value: StateRecord): Unit
```

Add a new state record to the beginning of a list. After this call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject#firstStateRecord()` should be `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/StateObject#prependStateRecord(androidx.compose.runtime.snapshots.StateRecord)`.

### remove

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun remove(element: T): Boolean
```

### removeAll

Cmn android

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

### removeAt

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open fun removeAt(index: Int): T
```

### removeRange

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

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

### retainAll

Cmn android

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

### set

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open operator fun set(index: Int, element: T): T
```

### subList

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

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

### toList

Cmn android Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.4.0)

```
fun toList(): List<T>
```

Return a list containing all the elements of this list.

The list returned is immutable and returned will not change even if the content of the list is changed in the same snapshot. It also will be the same instance until the content is changed. It is not, however, guaranteed to be the same instance for the same list as adding and removing the same item from the this list might produce a different instance with the same content.

This operation is O(1) and does not involve a physically copying the list. It instead returns the underlying immutable list used internally to store the content of the list.

It is recommended to use `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateList#toList()` when using returning the value of this list from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#snapshotFlow(kotlin.Function0)`.

### toString

android

```
open fun toString(): String
```

### toString

Cmn

```
open fun toString(): String
```

### writeToParcel

android Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.9.0)

```
open fun writeToParcel(parcel: Parcel, flags: Int): Unit
```

## Public properties

### firstStateRecord

Cmn android

```
open val firstStateRecord: StateRecord
```

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

### size

Cmn android Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0)

```
open val size: Int
```