# MutableScatterSet

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.MutableScatterSet) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/collection#1.4.0)

*** ** * ** ***


```
public final class MutableScatterSet<E extends Object> extends ScatterSet<@NonNull E>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.collection.ScatterSet](https://developer.android.com/reference/androidx/collection/ScatterSet)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) E\> ||
|   | ↳ | [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. 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 stored, nor does it make guarantees that the order remains constant over time.

This implementation is not thread-safe: if multiple threads access this container concurrently, and one or more threads modify the structure of the set (insertion or removal for instance), the calling code must provide the appropriate synchronization. Concurrent reads are however safe.

**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/MutableScatterSet#asSet()` to create a thin wrapper around a `https://developer.android.com/reference/androidx/collection/MutableScatterSet`. Please refer to `https://developer.android.com/reference/androidx/collection/MutableScatterSet#asSet()` for more details and caveats.

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

| See also |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html` |   |

## Summary

| ### Public constructors |
|---|
| `<E extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/collection/MutableScatterSet#MutableScatterSet(kotlin.Int)(int initialCapacity)` Creates a new `https://developer.android.com/reference/androidx/collection/MutableScatterSet` |

| ### Public methods |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#add(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Adds the specified element to the set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.Array)` into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.collections.Iterable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.collections.Iterable)` into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.ObjectList)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.ObjectList)` set into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.OrderedScatterSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.OrderedScatterSet)` set into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.ScatterSet)(@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> elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.ScatterSet)` set into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.sequences.Sequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.sequences.Sequence)` into this set. |
| `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/MutableScatterSet#asMutableSet()()` Wraps this `https://developer.android.com/reference/androidx/collection/ScatterSet` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html` interface. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#clear()()` Removes all elements from this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.Any)` from the set if it is present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.Array)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.collections.Iterable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.collections.Iterable)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.ObjectList)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.ObjectList)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.OrderedScatterSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.OrderedScatterSet)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.ScatterSet)(@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> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.ScatterSet)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.sequences.Sequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.sequences.Sequence)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Adds the specified element to the set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.Array)` into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.collections.Iterable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.collections.Iterable)` into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.ObjectList)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.ObjectList)` set into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.OrderedScatterSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.OrderedScatterSet)` set into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.ScatterSet)(@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> elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.ScatterSet)` set into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.sequences.Sequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.sequences.Sequence)` into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#remove(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull E element)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#remove(kotlin.Any)` from the set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.Array)` from the set, if present. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.collections.Iterable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.collections.Iterable)` from the set, if present. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.ObjectList)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.ObjectList)` from the set, if present. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.OrderedScatterSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.OrderedScatterSet)` from the set, if present. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.ScatterSet)(@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> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.ScatterSet)` from the set, if present. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.sequences.Sequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.sequences.Sequence)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeIf(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull 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/Boolean.html> predicate)` Removes any values for which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeIf(kotlin.Function1)` returns true. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(kotlin.collections.Collection)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Collection.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes all the entries in this set that are not contained in `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(kotlin.collections.Collection)`. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(androidx.collection.OrderedScatterSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements)` Removes all the entries in this set that are not contained in `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(androidx.collection.OrderedScatterSet)`. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(androidx.collection.ScatterSet)(@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> elements)` Removes all the entries in this set that are not contained in `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(androidx.collection.ScatterSet)`. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull 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/Boolean.html> predicate)` Removes all the elements in this set for which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(kotlin.Function1)` is `true`. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/MutableScatterSet#trim()()` Trims this `https://developer.android.com/reference/androidx/collection/MutableScatterSet`'s storage so it is sized appropriately to hold the current elements. |

### Inherited methods

From [androidx.collection.ScatterSet](https://developer.android.com/reference/androidx/collection/ScatterSet) `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.

## Public constructors

### MutableScatterSet

```
public <E extends Object> MutableScatterSet(int initialCapacity)
```

Creates a new `https://developer.android.com/reference/androidx/collection/MutableScatterSet`

| Parameters |
|---|---|
| `int initialCapacity` | The initial desired capacity for this container. the container will honor this value by guaranteeing its internal structures can hold that many elements without requiring any allocations. The initial capacity can be set to 0. |

## Public methods

### add

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

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

Adds the specified element to the set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E element` | The element to add to the set. |

| Returns |
|---|---|
| `boolean` | `true` if the element has been added or `false` if the element is already contained within the set. |

### addAll

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

```
public final boolean addAll(@NonNull E[] elements)
```

Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.Array)` into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements` | An array of elements to add to the set. |

| Returns |
|---|---|
| `boolean` | `true` if any of the specified elements were added to the collection, `false` if the collection was not modified. |

### addAll

```
public final boolean addAll(@NonNull Iterable<@NonNull E> elements)
```

Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.collections.Iterable)` into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | Iterable elements to add to the set. |

| Returns |
|---|---|
| `boolean` | `true` if any of the specified elements were added to the collection, `false` if the collection was not modified. |

### addAll

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

```
public final boolean addAll(@NonNull ObjectList<@NonNull E> elements)
```

Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.ObjectList)` set into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | An `https://developer.android.com/reference/androidx/collection/ObjectList` whose elements are to be added to the set |

| Returns |
|---|---|
| `boolean` | `true` if any of the specified elements were added to the collection, `false` if the collection was not modified. |

### addAll

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

```
public final boolean addAll(@NonNull OrderedScatterSet<@NonNull E> elements)
```

Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.OrderedScatterSet)` set into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A `https://developer.android.com/reference/androidx/collection/OrderedScatterSet` whose elements are to be added to the set |

| Returns |
|---|---|
| `boolean` | `true` if any of the specified elements were added to the collection, `false` if the collection was not modified. |

### addAll

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

```
public final boolean addAll(@NonNull ScatterSet<@NonNull E> elements)
```

Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(androidx.collection.ScatterSet)` set into this set.

| Parameters |
|---|---|
| `@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> elements` | A `https://developer.android.com/reference/androidx/collection/ScatterSet` whose elements are to be added to the set |

| Returns |
|---|---|
| `boolean` | `true` if any of the specified elements were added to the collection, `false` if the collection was not modified. |

### addAll

```
public final boolean addAll(@NonNull Sequence<@NonNull E> elements)
```

Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#addAll(kotlin.sequences.Sequence)` into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | The sequence of elements to add to the set. |

| Returns |
|---|---|
| `boolean` | `true` if any of the specified elements were added to the collection, `false` if the collection was not modified. |

### asMutableSet

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

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

Wraps this `https://developer.android.com/reference/androidx/collection/ScatterSet` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html` interface. The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-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/-mutable-set/index.html` and vice-versa. 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/-mutable-set/index.html` is in progress (and vice- versa), the results of the iteration are undefined.

**Note** : while this method is useful to use this `https://developer.android.com/reference/androidx/collection/MutableScatterSet` with APIs accepting `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html` interfaces, it is less efficient to do so than to use `https://developer.android.com/reference/androidx/collection/MutableScatterSet`'s APIs directly. While the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-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/-mutable-set/index.html` may require the allocation of temporary objects for access and iteration.

### clear

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

```
public final void clear()
```

Removes all elements from this set.

### minusAssign

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

```
public final void minusAssign(@NonNull E element)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.Any)` from the set if it is present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E element` | The element to be removed from the set. |

### minusAssign

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

```
public final void minusAssign(@NonNull E[] elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.Array)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements` | An array of elements to be removed from the set. |

### minusAssign

```
public final void minusAssign(@NonNull Iterable<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.collections.Iterable)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A Iterable of elements to be removed from the set. |

### minusAssign

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

```
public final void minusAssign(@NonNull ObjectList<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.ObjectList)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | An `https://developer.android.com/reference/androidx/collection/ObjectList` whose elements should be removed from the set. |

### minusAssign

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

```
public final void minusAssign(@NonNull OrderedScatterSet<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.OrderedScatterSet)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A `https://developer.android.com/reference/androidx/collection/OrderedScatterSet` whose elements should be removed from the set. |

### minusAssign

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

```
public final void minusAssign(@NonNull ScatterSet<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(androidx.collection.ScatterSet)` from the set, if present.

| Parameters |
|---|---|
| `@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> elements` | A `https://developer.android.com/reference/androidx/collection/ScatterSet` whose elements should be removed from the set. |

### minusAssign

```
public final void minusAssign(@NonNull Sequence<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#minusAssign(kotlin.sequences.Sequence)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A sequence of elements to be removed from the set. |

### plusAssign

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

```
public final void plusAssign(@NonNull E element)
```

Adds the specified element to the set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E element` | The element to add to the set. |

### plusAssign

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

```
public final void plusAssign(@NonNull E[] elements)
```

Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.Array)` into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements` | An array of elements to add to the set. |

### plusAssign

```
public final void plusAssign(@NonNull Iterable<@NonNull E> elements)
```

Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.collections.Iterable)` into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | Iterable elements to add to the set. |

### plusAssign

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

```
public final void plusAssign(@NonNull ObjectList<@NonNull E> elements)
```

Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.ObjectList)` set into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | An `https://developer.android.com/reference/androidx/collection/ObjectList` whose elements are to be added to the set |

### plusAssign

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

```
public final void plusAssign(@NonNull OrderedScatterSet<@NonNull E> elements)
```

Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.OrderedScatterSet)` set into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A `https://developer.android.com/reference/androidx/collection/OrderedScatterSet` whose elements are to be added to the set |

### plusAssign

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

```
public final void plusAssign(@NonNull ScatterSet<@NonNull E> elements)
```

Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(androidx.collection.ScatterSet)` set into this set.

| Parameters |
|---|---|
| `@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> elements` | A `https://developer.android.com/reference/androidx/collection/ScatterSet` whose elements are to be added to the set |

### plusAssign

```
public final void plusAssign(@NonNull Sequence<@NonNull E> elements)
```

Adds all the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#plusAssign(kotlin.sequences.Sequence)` into this set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | The sequence of elements to add to the set. |

### remove

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

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

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#remove(kotlin.Any)` from the set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E element` | The element to be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the `https://developer.android.com/reference/androidx/collection/MutableScatterSet#remove(kotlin.Any)` was present in the set, or `false` if it wasn't present before removal. |

### removeAll

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

```
public final boolean removeAll(@NonNull E[] elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.Array)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull E[] elements` | An array of elements to be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the set was changed or `false` if none of the elements were present. |

### removeAll

```
public final boolean removeAll(@NonNull Iterable<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.collections.Iterable)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Iterable.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A Iterable of elements to be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the set was changed or `false` if none of the elements were present. |

### removeAll

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

```
public final boolean removeAll(@NonNull ObjectList<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.ObjectList)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ObjectList<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | An `https://developer.android.com/reference/androidx/collection/ObjectList` whose elements should be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the set was changed or `false` if none of the elements were present. |

### removeAll

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

```
public final boolean removeAll(@NonNull OrderedScatterSet<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.OrderedScatterSet)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/OrderedScatterSet<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A `https://developer.android.com/reference/androidx/collection/OrderedScatterSet` whose elements should be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the set was changed or `false` if none of the elements were present. |

### removeAll

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

```
public final boolean removeAll(@NonNull ScatterSet<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(androidx.collection.ScatterSet)` from the set, if present.

| Parameters |
|---|---|
| `@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> elements` | A `https://developer.android.com/reference/androidx/collection/ScatterSet` whose elements should be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the set was changed or `false` if none of the elements were present. |

### removeAll

```
public final boolean removeAll(@NonNull Sequence<@NonNull E> elements)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeAll(kotlin.sequences.Sequence)` from the set, if present.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A sequence of elements to be removed from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the set was changed or `false` if none of the elements were present. |

### removeIf

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

```
public final void removeIf(@NonNull Function1<@NonNull E, @NonNull Boolean> predicate)
```

Removes any values for which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#removeIf(kotlin.Function1)` returns true.

### retainAll

```
public final boolean retainAll(@NonNull Collection<@NonNull E> elements)
```

Removes all the entries in this set that are not contained in `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(kotlin.collections.Collection)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Collection.html<@https://developer.android.com/reference/androidx/annotation/NonNull E> elements` | A collection of elements to preserve in this set. |

| Returns |
|---|---|
| `boolean` | `true` if this set was modified, `false` otherwise. |

### retainAll

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

```
public final boolean retainAll(@NonNull OrderedScatterSet<@NonNull E> elements)
```

Removes all the entries in this set that are not contained in `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(androidx.collection.OrderedScatterSet)`.

elements A set of elements to preserve in this set.

| Returns |
|---|---|
| `boolean` | `true` if this set was modified, `false` otherwise. |

### retainAll

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

```
public final boolean retainAll(@NonNull ScatterSet<@NonNull E> elements)
```

Removes all the entries in this set that are not contained in `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(androidx.collection.ScatterSet)`.

elements A set of elements to preserve in this set.

| Returns |
|---|---|
| `boolean` | `true` if this set was modified, `false` otherwise. |

### retainAll

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

```
public final boolean retainAll(@NonNull Function1<@NonNull E, @NonNull Boolean> predicate)
```

Removes all the elements in this set for which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterSet#retainAll(kotlin.Function1)` is `true`. For each element in the set, the predicate is invoked with that element as the sole parameter.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull 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/Boolean.html> predicate` | Predicate invoked for each element in the set. When the predicate returns `true`, the element is kept in the set, otherwise it is removed. |

| Returns |
|---|---|
| `boolean` | `true` if this set was modified, `false` otherwise. |

### trim

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

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

Trims this `https://developer.android.com/reference/androidx/collection/MutableScatterSet`'s storage so it is sized appropriately to hold the current elements.

Returns the number of empty elements removed from this set's storage. Returns 0 if no trimming is necessary or possible.