# SnapshotStateSet

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/SnapshotStateSet.+class:androidx.compose.runtime.snapshots.SnapshotStateSet) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class SnapshotStateSet<T : Any?> : StateObject, MutableSet<T>, RandomAccess
  ```

*** ** * ** ***

An implementation of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/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#mutableStateSetOf()`.

The returned set iteration order is in the order the items were inserted into the set.

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

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

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#add(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/SnapshotStateSet#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/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#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/SnapshotStateSet#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/SnapshotStateSet#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/SnapshotStateSet#describeContents()()` | android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#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/SnapshotStateSet#iterator()()` | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#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/SnapshotStateSet#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/SnapshotStateSet#removeAll(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/SnapshotStateSet#retainAll(kotlin.collections.Collection)(elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<T>)` | Cmn android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<T>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#toSet()()` Return a set containing all the elements of this set. | Cmn android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#toString()()` | android |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#toString()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#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/SnapshotStateSet#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/SnapshotStateSet#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.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.Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html) `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/-set/spliterator.html()` 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

### SnapshotStateSet

android

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

### SnapshotStateSet

Cmn

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

### SnapshotStateSet

Cmn

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

## Public functions

### add

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

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

### addAll

Cmn android

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

### clear

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

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

### contains

Cmn android Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.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
```

### isEmpty

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

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

### iterator

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

```
open operator fun iterator(): MutableIterator<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.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

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

### removeAll

Cmn android

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

### retainAll

Cmn android

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

### toSet

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

```
fun toSet(): Set<T>
```

Return a set containing all the elements of this set.

The set returned is immutable and returned will not change even if the content of the set 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 set as adding and removing the same item from the this set might produce a different instance with the same content.

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

It is recommended to use `https://developer.android.com/reference/kotlin/androidx/compose/runtime/snapshots/SnapshotStateSet#toSet()` when returning the value of this set 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.8.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.8.0)

```
open val size: Int
```