---
title: "SnapshotStateSet"
description: "An implementation of [MutableSet] that can be observed and snapshot. This is the result type
created by [androidx.compose.runtime.mutableStateSetOf]."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-nonAndroid'>NonAndroid</div>


```kotlin
public actual class SnapshotStateSet<T> : StateObject, MutableSet<T>, RandomAccess
```


An implementation of `MutableSet` that can be observed and snapshot. This is the result type
created by `androidx.compose.runtime.mutableStateSetOf`.


## Functions

```kotlin
public actual 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 `toSet` when returning the value of this set from
`androidx.compose.runtime.snapshotFlow`.


<div class='sourceset sourceset-common'>Common</div>


```kotlin
public expect class SnapshotStateSet<T> : StateObject, MutableSet<T>, RandomAccess
```


An implementation of `MutableSet` that can be observed and snapshot. This is the result type
created by `androidx.compose.runtime.mutableStateSetOf`.

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


## Secondary Constructors

```kotlin
public constructor()
```

## Functions

```kotlin
public 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 `toSet` when returning the value of this set from
`androidx.compose.runtime.snapshotFlow`.


<div class='sourceset sourceset-android'>Android</div>


```kotlin
@SuppressLint("BanParcelableUsage")
public actual class SnapshotStateSet<T> : Parcelable, StateObject, MutableSet<T>, RandomAccess
```


An implementation of `MutableSet` that can be observed and snapshot. This is the result type
created by `androidx.compose.runtime.mutableStateSetOf`.


## Functions

```kotlin
public actual 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 `toSet` when returning the value of this set from
`androidx.compose.runtime.snapshotFlow`.


## Companion Object

#### Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
@JvmField
    val CREATOR: Parcelable.Creator<SnapshotStateSet<Any?>>
```




