# SubcomposeSlotReusePolicy.SlotIdsSet

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/layout/SubcomposeLayout.kt+class:androidx.compose.ui.layout.SubcomposeSlotReusePolicy.SlotIdsSet) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0) Common/AllAndroid/JVM
- Cmn

  ```
  class SubcomposeSlotReusePolicy.SlotIdsSet : Collection<Any?>
  ```

*** ** * ** ***

Set containing slot ids currently available to reuse. Used by `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy#getSlotsToRetain(androidx.compose.ui.layout.SubcomposeSlotReusePolicy.SlotIdsSet)`. The set retains the insertion order of its elements, guaranteeing stable iteration order.

This class works exactly as `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html`, but doesn't allow to add new items in it.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#clear()()` Removes all slot ids from this set. | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#contains(kotlin.Any)(element: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#containsAll(kotlin.collections.Collection)(elements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>)` | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#fastForEach(kotlin.Function1)(block: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Iterates over every element stored in this set by invoking the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#fastForEach(kotlin.Function1)` lambda. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#forEach(kotlin.Function1)(block: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Iterates over every element stored in this set by invoking the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#forEach(kotlin.Function1)` lambda. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#isEmpty()()` | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterator/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#iterator()()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#remove(kotlin.Any)(slotId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` Removes a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#remove(kotlin.Any)` from this set, if it is present. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#removeAll(kotlin.Function1)(predicate: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Removes all slot ids that match the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#removeAll(kotlin.Function1)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#removeAll(kotlin.collections.Collection)(slotIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>)` Removes all slot ids from `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#removeAll(kotlin.collections.Collection)` that are also contained in this set. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#retainAll(kotlin.Function1)(predicate: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Retains only slotIds that match the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#retainAll(kotlin.Function1)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#retainAll(kotlin.collections.Collection)(slotIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>)` Retains only the slot ids that are contained in `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#retainAll(kotlin.collections.Collection)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#trimToSize(kotlin.Int)(maxSlotsToRetainForReuse: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Remove entries until `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#size()` equals `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#trimToSize(kotlin.Int)`. | Cmn |

| ### Public properties |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#size()` | Cmn |

## Public functions

### clear

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

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

Removes all slot ids from this set.

### contains

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

```
open operator fun contains(element: Any?): Boolean
```

### containsAll

Cmn

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

### fastForEach

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

```
inline fun fastForEach(block: (Any?) -> Unit): Unit
```

Iterates over every element stored in this set by invoking the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#fastForEach(kotlin.Function1)` lambda. The iteration order is the same as the insertion order. It is safe to remove the element passed to `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#fastForEach(kotlin.Function1)` during iteration.

NOTE: this method was added in order to allow for a more performant forEach method. It is necessary because `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#forEach(kotlin.Function1)` is obscured by `Collection<T>.forEach` since it is marked with @HidesMember.

### forEach

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

```
fun forEach(block: (Any?) -> Unit): Unit
```

Iterates over every element stored in this set by invoking the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#forEach(kotlin.Function1)` lambda. The iteration order is the same as the insertion order. It is safe to remove the element passed to `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#forEach(kotlin.Function1)` during iteration.

NOTE: This method is obscured by `Collection<T>.forEach` since it is marked with

, which means in practice this will never get called. Please use `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#fastForEach(kotlin.Function1)` instead.

### isEmpty

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

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

### iterator

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

```
open operator fun iterator(): MutableIterator<Any?>
```

### remove

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

```
fun remove(slotId: Any?): Boolean
```

Removes a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#remove(kotlin.Any)` from this set, if it is present.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the slot id was removed, `false` if the set was not modified. |

### removeAll

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

```
fun removeAll(predicate: (Any?) -> Boolean): Boolean
```

Removes all slot ids that match the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#removeAll(kotlin.Function1)`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if any slot id was removed, `false` if the set was not modified. |

### removeAll

Cmn

```
fun removeAll(slotIds: Collection<Any?>): Boolean
```

Removes all slot ids from `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#removeAll(kotlin.collections.Collection)` that are also contained in this set.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if any slot id was removed, `false` if the set was not modified. |

### retainAll

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

```
fun retainAll(predicate: (Any?) -> Boolean): Boolean
```

Retains only slotIds that match the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#retainAll(kotlin.Function1)`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if any slot id was removed, `false` if the set was not modified. |

### retainAll

Cmn

```
fun retainAll(slotIds: Collection<Any?>): Boolean
```

Retains only the slot ids that are contained in `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#retainAll(kotlin.collections.Collection)`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if any slot id was removed, `false` if the set was not modified. |

### trimToSize

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

```
fun trimToSize(maxSlotsToRetainForReuse: Int): Unit
```

Remove entries until `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#size()` equals `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeSlotReusePolicy.SlotIdsSet#trimToSize(kotlin.Int)`. Entries inserted last are removed first.

## Public properties

### size

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

```
open val size: Int
```