# MutableFloatSet

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

*** ** * ** ***


```
public final class MutableFloatSet extends FloatSet
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.collection.FloatSet](https://developer.android.com/reference/androidx/collection/FloatSet) ||
|   | ↳ | [androidx.collection.MutableFloatSet](https://developer.android.com/reference/androidx/collection/MutableFloatSet) |

*** ** * ** ***

`https://developer.android.com/reference/androidx/collection/MutableFloatSet` 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.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/collection/MutableFloatSet#MutableFloatSet(kotlin.Int)(int initialCapacity)` Creates a new `https://developer.android.com/reference/androidx/collection/MutableFloatSet` |

| ### Public methods |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#add(kotlin.Float)(float element)` Adds the specified element to the set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#addAll(kotlin.FloatArray)(@https://developer.android.com/reference/androidx/annotation/NonNull float[] elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableFloatSet#addAll(kotlin.FloatArray)` into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#addAll(androidx.collection.FloatSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableFloatSet#addAll(androidx.collection.FloatSet)` set into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#clear()()` Removes all elements from this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#minusAssign(kotlin.Float)(float element)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableFloatSet#minusAssign(kotlin.Float)` from the set if it is present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#minusAssign(kotlin.FloatArray)(@https://developer.android.com/reference/androidx/annotation/NonNull float[] elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableFloatSet#minusAssign(kotlin.FloatArray)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#minusAssign(androidx.collection.FloatSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableFloatSet#minusAssign(androidx.collection.FloatSet)` from the set, if present. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#plusAssign(kotlin.Float)(float element)` Adds the specified element to the set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#plusAssign(kotlin.FloatArray)(@https://developer.android.com/reference/androidx/annotation/NonNull float[] elements)` Adds all the `https://developer.android.com/reference/androidx/collection/MutableFloatSet#plusAssign(kotlin.FloatArray)` into this set. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#plusAssign(androidx.collection.FloatSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements)` Adds all the elements in the `https://developer.android.com/reference/androidx/collection/MutableFloatSet#plusAssign(androidx.collection.FloatSet)` set into this set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#remove(kotlin.Float)(float element)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableFloatSet#remove(kotlin.Float)` from the set. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#removeAll(kotlin.FloatArray)(@https://developer.android.com/reference/androidx/annotation/NonNull float[] elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableFloatSet#removeAll(kotlin.FloatArray)` from the set, if present. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#removeAll(androidx.collection.FloatSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableFloatSet#removeAll(androidx.collection.FloatSet)` from the set, if present. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/MutableFloatSet#trim()()` Trims this `https://developer.android.com/reference/androidx/collection/MutableFloatSet`'s storage so it is sized appropriately to hold the current elements. |

| ### Inherited methods |
|---|
| From [androidx.collection.FloatSet](https://developer.android.com/reference/androidx/collection/FloatSet) |---|---| | `final boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#all(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, @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/FloatSet#all(kotlin.Function1)`. | | `final boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#any()()` Returns `true` if this set has at least one element. | | `final boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#any(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, @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/FloatSet#any(kotlin.Function1)`. | | `final boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#contains(kotlin.Float)(float element)` Returns `true` if the specified `https://developer.android.com/reference/androidx/collection/FloatSet#contains(kotlin.Float)` is present in this set, `false` otherwise. | | `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/FloatSet#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/FloatSet#count(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, @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/FloatSet#count(kotlin.Function1)`. | | `boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` Compares the specified object `https://developer.android.com/reference/androidx/collection/FloatSet#equals(kotlin.Any)` with this set for equality. | | `final float` | `https://developer.android.com/reference/androidx/collection/FloatSet#first()()` Returns the first element in the collection. | | `final float` | `https://developer.android.com/reference/androidx/collection/FloatSet#first(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, @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/FloatSet#first(kotlin.Function1)` returns `true`. | | `final void` | `https://developer.android.com/reference/androidx/collection/FloatSet#forEach(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, 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/FloatSet#forEach(kotlin.Function1)` lambda. | | `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/collection/FloatSet#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/FloatSet#getSize()()` Returns the number of elements in this set. | | `int` | `https://developer.android.com/reference/androidx/collection/FloatSet#hashCode()()` Returns the hash code value for this set. | | `final boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#isEmpty()()` Indicates whether this set is empty. | | `final boolean` | `https://developer.android.com/reference/androidx/collection/FloatSet#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/FloatSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence)( @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 )` Creates a String from the elements separated by `https://developer.android.com/reference/androidx/collection/FloatSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence)` and using `https://developer.android.com/reference/androidx/collection/FloatSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence)` before and `https://developer.android.com/reference/androidx/collection/FloatSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence)` after, if supplied. | | `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/FloatSet#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, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, @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/FloatSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` and using `https://developer.android.com/reference/androidx/collection/FloatSet#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function1)` before and `https://developer.android.com/reference/androidx/collection/FloatSet#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/FloatSet#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/FloatSet#toString()()` Returns a string representation of this set. | |

## Public constructors

### MutableFloatSet

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

```
public MutableFloatSet(int initialCapacity)
```

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

| 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(float element)
```

Adds the specified element to the set.

| Parameters |
|---|---|
| `float 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 float[] elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] 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

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

```
public final boolean addAll(@NonNull FloatSet elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements` | A `https://developer.android.com/reference/androidx/collection/FloatSet` of elements to add to this set. |

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

### 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(float element)
```

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

| Parameters |
|---|---|
| `float element` | The element to remove 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 float[] elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] elements` | An array 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 FloatSet elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements` | An `https://developer.android.com/reference/androidx/collection/FloatSet` 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(float element)
```

Adds the specified element to the set.

| Parameters |
|---|---|
| `float 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 float[] elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] elements` | An array of 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 FloatSet elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements` | A `https://developer.android.com/reference/androidx/collection/FloatSet` of elements to add to this set. |

### remove

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

```
public final boolean remove(float element)
```

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

| Parameters |
|---|---|
| `float element` | The element to remove from the set. |

| Returns |
|---|---|
| `boolean` | `true` if the `https://developer.android.com/reference/androidx/collection/MutableFloatSet#remove(kotlin.Float)` 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 float[] elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] 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

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

```
public final boolean removeAll(@NonNull FloatSet elements)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/FloatSet elements` | An `https://developer.android.com/reference/androidx/collection/FloatSet` 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. |

### 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/MutableFloatSet`'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.