# ScatterSet

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/ScatterSet.+class:androidx.collection.ScatterSet) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

*** ** * ** ***


```
public sealed class ScatterSet<E extends Object>
```

<br />

Known direct subclasses [MutableScatterSet](https://developer.android.com/reference/androidx/collection/MutableScatterSet)

|---|---|
| `https://developer.android.com/reference/androidx/collection/MutableScatterSet` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet` is a container with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html`-like interface based on a flat hash table implementation. |

*** ** * ** ***

`https://developer.android.com/reference/androidx/collection/ScatterSet` is a container with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html`-like interface based on a flat hash table implementation. The underlying implementation is designed to avoid all allocations on insertion, removal, retrieval, and iteration. Allocations may still happen on insertion when the underlying storage needs to grow to accommodate newly added elements to the set.

This implementation makes no guarantee as to the order of the elements, nor does it make guarantees that the order remains constant over time. If the order of the elements must be preserved, please refer to `https://developer.android.com/reference/androidx/collection/OrderedScatterSet`.

Though `https://developer.android.com/reference/androidx/collection/ScatterSet` offers a read-only interface, it is always backed by a `https://developer.android.com/reference/androidx/collection/MutableScatterSet`. Read operations alone are thread-safe. However, any mutations done through the backing `https://developer.android.com/reference/androidx/collection/MutableScatterSet` while reading on another thread are not safe and the developer must protect the set from such changes during read operations.

**Note** : when a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` is absolutely necessary, you can use the method `https://developer.android.com/reference/androidx/collection/ScatterSet#asSet()` to create a thin wrapper around a `https://developer.android.com/reference/androidx/collection/ScatterSet`. Please refer to `https://developer.android.com/reference/androidx/collection/ScatterSet#asSet()` for more details and caveats.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/collection/MutableScatterSet` |   |

## Summary

| ### Protected constructors |
|---|
| `<E extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ScatterSet#ScatterSet()()` |

| ### Public methods |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#all(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns true if all elements match the given `https://developer.android.com/reference/androidx/collection/ScatterSet#all(kotlin.Function1)`. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#any()()` Returns `true` if this set has at least one element. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#any(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns true if at least one element matches the given `https://developer.android.com/reference/androidx/collection/ScatterSet#any(kotlin.Function1)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull E>` | `https://developer.android.com/reference/androidx/collection/ScatterSet#asSet()()` Wraps this `https://developer.android.com/reference/androidx/collection/ScatterSet` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` interface. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#contains(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Returns true if the specified `https://developer.android.com/reference/androidx/collection/ScatterSet#contains(kotlin.Any)` is present in this hash set, false otherwise. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/ScatterSet#count()()` Returns the number of elements in this set. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/ScatterSet#count(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns the number of elements matching the given `https://developer.android.com/reference/androidx/collection/ScatterSet#count(kotlin.Function1)`. |
| `boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` Compares the specified object `https://developer.android.com/reference/androidx/collection/ScatterSet#equals(kotlin.Any)` with this hash set for equality. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ScatterSet#first()()` Returns the first element in the collection. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull E` | `https://developer.android.com/reference/androidx/collection/ScatterSet#first(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)` Returns the first element in the collection for which `https://developer.android.com/reference/androidx/collection/ScatterSet#first(kotlin.Function1)` returns `true` |
| `final E` | `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate )` Returns the first element in the collection for which `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)` returns `true` or `null` if there are no elements that match `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)`. |
| `final void` | `https://developer.android.com/reference/androidx/collection/ScatterSet#forEach(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Iterates over every element stored in this set by invoking the specified `https://developer.android.com/reference/androidx/collection/ScatterSet#forEach(kotlin.Function1)` lambda. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/ScatterSet#getCapacity()()` Returns the number of elements that can be stored in this set without requiring internal storage reallocation. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/ScatterSet#getSize()()` Returns the number of elements in this set. |
| `int` | `https://developer.android.com/reference/androidx/collection/ScatterSet#hashCode()()` Returns the hash code value for this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#isEmpty()()` Indicates whether this set is empty. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#isNotEmpty()()` Returns `true` if this set is not empty. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html separator, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html prefix, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html postfix, int limit, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html truncated, Function1<@https://developer.android.com/reference/androidx/annotation/NonNull E, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html> transform )` Creates a String from the elements separated by `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` and using `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` before and `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` after, if supplied. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/ScatterSet#none()()` Returns `true` if this set has no elements. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/collection/ScatterSet#toString()()` Returns a string representation of this set. |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/MutableScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E>` | `<E extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ScatterSetKt.https://developer.android.com/reference/androidx/collection/ScatterSet#(androidx.collection.ScatterSet).toMutableScatterSet()( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> receiver )` Returns a new `https://developer.android.com/reference/androidx/collection/MutableScatterSet` with the specified contents. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E>` | `<E extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/ScatterSetKt.https://developer.android.com/reference/androidx/collection/ScatterSet#(androidx.collection.ScatterSet).toScatterSet()( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> receiver )` Returns a new read-only `https://developer.android.com/reference/androidx/collection/ScatterSet` with the specified contents. |

## Protected constructors

### ScatterSet

```
protected <E extends Object> ScatterSet()
```

## Public methods

### all

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean all(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns true if all elements match the given `https://developer.android.com/reference/androidx/collection/ScatterSet#all(kotlin.Function1)`. If there are no elements in the set, `true` is returned.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate` | called for elements in the set to determine if it returns return `true` for all elements. |

### any

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean any()
```

Returns `true` if this set has at least one element.

### any

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean any(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns true if at least one element matches the given `https://developer.android.com/reference/androidx/collection/ScatterSet#any(kotlin.Function1)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate` | called for elements in the set to determine if it returns `true` for any elements. |

### asSet

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull Set<@NonNull E> asSet()
```

Wraps this `https://developer.android.com/reference/androidx/collection/ScatterSet` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` interface. The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` is backed by the `https://developer.android.com/reference/androidx/collection/ScatterSet`, so changes to the `https://developer.android.com/reference/androidx/collection/ScatterSet` are reflected in the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html`. If the `https://developer.android.com/reference/androidx/collection/ScatterSet` is modified while an iteration over the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` is in progress, the results of the iteration are undefined.

**Note** : while this method is useful to use this `https://developer.android.com/reference/androidx/collection/ScatterSet` with APIs accepting `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` interfaces, it is less efficient to do so than to use `https://developer.android.com/reference/androidx/collection/ScatterSet`'s APIs directly. While the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` implementation returned by this method tries to be as efficient as possible, the semantics of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` may require the allocation of temporary objects for access and iteration.

### contains

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean contains(@NonNull E element)
```

Returns true if the specified `https://developer.android.com/reference/androidx/collection/ScatterSet#contains(kotlin.Any)` is present in this hash set, false otherwise.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E element` | The element to look for in this set |

### count

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @IntRange(from = 0) int count()
```

Returns the number of elements in this set.

### count

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @IntRange(from = 0) int count(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns the number of elements matching the given `https://developer.android.com/reference/androidx/collection/ScatterSet#count(kotlin.Function1)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate` | Called for all elements in the set to count the number for which it returns `true`. |

### equals

```
public boolean equals(Object other)
```

Compares the specified object `https://developer.android.com/reference/androidx/collection/ScatterSet#equals(kotlin.Any)` with this hash set for equality. The two objects are considered equal if `https://developer.android.com/reference/androidx/collection/ScatterSet#equals(kotlin.Any)`:

- Is a `https://developer.android.com/reference/androidx/collection/ScatterSet`

- Has the same `https://developer.android.com/reference/androidx/collection/ScatterSet#size()` as this set

- Contains elements equal to this set's elements

### first

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E first()
```

Returns the first element in the collection.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` | if the collection is empty |

### first

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @NonNull E first(@NonNull Function1<@NonNull element, @NonNull Boolean> predicate)
```

Returns the first element in the collection for which `https://developer.android.com/reference/androidx/collection/ScatterSet#first(kotlin.Function1)` returns `true`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate` | called with each element until it returns `true`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E` | The element for which `https://developer.android.com/reference/androidx/collection/ScatterSet#first(kotlin.Function1)` returns `true`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-no-such-element-exception/index.html` | if `https://developer.android.com/reference/androidx/collection/ScatterSet#first(kotlin.Function1)` returns `false` for all elements or the collection is empty. |

### firstOrNull

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final E firstOrNull(
    @NonNull Function1<@NonNull element, @NonNull Boolean> predicate
)
```

Returns the first element in the collection for which `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)` returns `true` or `null` if there are no elements that match `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate` | called with each element until it returns `true`. |

| Returns |
|---|---|
| `E` | The element for which `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)` returns `true` or `null` if there are no elements in the set or `https://developer.android.com/reference/androidx/collection/ScatterSet#firstOrNull(kotlin.Function1)` returned `false` for every element in the set. |

### forEach

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final void forEach(@NonNull Function1<@NonNull element, Unit> block)
```

Iterates over every element stored in this set by invoking the specified `https://developer.android.com/reference/androidx/collection/ScatterSet#forEach(kotlin.Function1)` lambda. It is safe to remove the element passed to `https://developer.android.com/reference/androidx/collection/ScatterSet#forEach(kotlin.Function1)` during iteration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull element, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | called with each element in the set |

### getCapacity

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @IntRange(from = 0) int getCapacity()
```

Returns the number of elements that can be stored in this set without requiring internal storage reallocation.

### getSize

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final @IntRange(from = 0) int getSize()
```

Returns the number of elements in this set.

### hashCode

```
public int hashCode()
```

Returns the hash code value for this set. The hash code of a set is based on the sum of the hash codes of the elements in the set, where the hash code of a null element is defined to be zero.

### isEmpty

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean isEmpty()
```

Indicates whether this set is empty.

### isNotEmpty

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean isNotEmpty()
```

Returns `true` if this set is not empty.

### joinToString

```
public final @NonNull String joinToString(
    @NonNull CharSequence separator,
    @NonNull CharSequence prefix,
    @NonNull CharSequence postfix,
    int limit,
    @NonNull CharSequence truncated,
    Function1<@NonNull E, @NonNull CharSequence> transform
)
```

Creates a String from the elements separated by `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` and using `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` before and `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` after, if supplied.

When a non-negative value of `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` is provided, a maximum of `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` items are used to generate the string. If the collection holds more than `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` items, the string is terminated with `https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)`.

`https://developer.android.com/reference/androidx/collection/ScatterSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` may be supplied to convert each element to a custom String.

### none

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

```
public final boolean none()
```

Returns `true` if this set has no elements.

### toString

```
public @NonNull String toString()
```

Returns a string representation of this set. The set is denoted in the string by the `[]`. Each element is separated by `, `.

## Extension functions

### ScatterSetKt.toMutableScatterSet

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/ScatterSet.kt+function:toMutableScatterSet)

```
public final @NonNull MutableScatterSet<@NonNull E> <E extends Object> ScatterSetKt.toMutableScatterSet(
    @NonNull ScatterSet<@NonNull E> receiver
)
```

Returns a new `https://developer.android.com/reference/androidx/collection/MutableScatterSet` with the specified contents.

The `https://developer.android.com/reference/androidx/collection/MutableScatterSet` is created with an initial capacity sufficient to hold the content in the specified `https://developer.android.com/reference/androidx/collection/ScatterSet`.

### ScatterSetKt.toScatterSet

Artifact: [androidx.collection:collection](https://developer.android.com/jetpack/androidx/releases/collection) [View Source](https://cs.android.com/search?q=file:androidx/collection/ScatterSet.kt+function:toScatterSet)

```
public final @NonNull ScatterSet<@NonNull E> <E extends Object> ScatterSetKt.toScatterSet(
    @NonNull ScatterSet<@NonNull E> receiver
)
```

Returns a new read-only `https://developer.android.com/reference/androidx/collection/ScatterSet` with the specified contents.