# MutableScatterMap

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

*** ** * ** ***


```
public final class MutableScatterMap<K extends Object, V extends Object> extends ScatterMap<@NonNull K, @NonNull V>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.collection.ScatterMap](https://developer.android.com/reference/androidx/collection/ScatterMap)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) K, @[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) V\> ||
|   | ↳ | [androidx.collection.MutableScatterMap](https://developer.android.com/reference/androidx/collection/MutableScatterMap) |

*** ** * ** ***

`https://developer.android.com/reference/androidx/collection/MutableScatterMap` is a container with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html`-like interface based on a flat hash table implementation (the key/value mappings are not stored by nodes but directly into arrays). 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 entries to the table. In addition, this implementation minimizes memory usage by avoiding the use of separate objects to hold key/value pairs.

This implementation makes no guarantee as to the order of the keys and values 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 map (insertion or removal for instance), the calling code must provide the appropriate synchronization. Multiple threads are safe to read from this map concurrently if no write is happening.

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

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

**MutableScatterMap and SimpleArrayMap** : like `https://developer.android.com/reference/androidx/collection/SimpleArrayMap`, `https://developer.android.com/reference/androidx/collection/MutableScatterMap` is designed to avoid the allocation of extra objects when inserting new entries in the map. However, the implementation of `https://developer.android.com/reference/androidx/collection/MutableScatterMap` offers better performance characteristics compared to `https://developer.android.com/reference/androidx/collection/SimpleArrayMap` and is thus generally preferable. If memory usage is a concern, `https://developer.android.com/reference/androidx/collection/SimpleArrayMap` automatically shrinks its storage to avoid using more memory than necessary. You can also control memory usage with `https://developer.android.com/reference/androidx/collection/MutableScatterMap` by manually calling `https://developer.android.com/reference/androidx/collection/MutableScatterMap#trim()`.

**Note**: For the JS target the implementation delegates to a regular map.

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

## Summary

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

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V>` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#asMutableMap()()` Wraps this `https://developer.android.com/reference/androidx/collection/ScatterMap` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html` interface. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#clear()()` Removes all mappings from this map. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull V` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#compute(kotlin.Any,kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull key, value, @https://developer.android.com/reference/androidx/annotation/NonNull V> computeBlock )` Retrieves a value for `https://developer.android.com/reference/androidx/collection/MutableScatterMap#compute(kotlin.Any,kotlin.Function2)` and computes a new value based on the existing value (or `null` if the key is not in the map). |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull V` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#getOrPut(kotlin.Any,kotlin.Function0)(@https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull V> defaultValue)` Returns the value to which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#getOrPut(kotlin.Any,kotlin.Function0)` is mapped, if the value is present in the map and not `null`. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.Any)` and its associated value from the map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull K[] keys)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.Array)` and their associated value from the map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#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 K> keys)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.collections.Iterable)` and their associated value from the map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#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 K> keys)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(androidx.collection.ObjectList)` and their associated value from the map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#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 K> keys)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(androidx.collection.ScatterSet)` and their associated value from the map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#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 K> keys)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.sequences.Sequence)` and their associated value from the map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.collections.Map)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V> from)` Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.collections.Map)` map into this map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(androidx.collection.ScatterMap)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ScatterMap<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V> from)` Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(androidx.collection.ScatterMap)` map into this map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.Pair)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V> pair)` Puts the key/value mapping from the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.Pair)` in this map, using the first element as the key, and the second element as the value. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull Pair[] pairs)` Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.Array)` into this map, using the first component of the pair as the key, and the second component as the value. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V>> pairs)` Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.collections.Iterable)` into this map, using the first component of the pair as the key, and the second component as the value. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V>> pairs)` Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.sequences.Sequence)` into this map, using the first component of the pair as the key, and the second component as the value. |
| `final V` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull V value)` Creates a new mapping from `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)` to `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)` in this map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.collections.Map)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V> from)` Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.collections.Map)` map into this map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(androidx.collection.ScatterMap)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/collection/ScatterMap<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V> from)` Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(androidx.collection.ScatterMap)` map into this map. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull Pair[] pairs)` Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.Array)` into this map, using the first component of the pair as the key, and the second component as the value. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V>> pairs)` Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.collections.Iterable)` into this map, using the first component of the pair as the key, and the second component as the value. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(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 https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V>> pairs)` Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.sequences.Sequence)` into this map, using the first component of the pair as the key, and the second component as the value. |
| `final V` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any)` and its associated value from the map. |
| `final boolean` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull V value)` Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any,kotlin.Any)` and its associated value from the map if the associated value equals `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any,kotlin.Any)`. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#removeIf(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate )` Removes any mapping for which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#removeIf(kotlin.Function2)` returns true. |
| `final void` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull V value)` Creates a new mapping from `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)` to `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)` in this map. |
| `final int` | `https://developer.android.com/reference/androidx/collection/MutableScatterMap#trim()()` Trims this `https://developer.android.com/reference/androidx/collection/MutableScatterMap`'s storage so it is sized appropriately to hold the current mappings. |

### Inherited methods

From [androidx.collection.ScatterMap](https://developer.android.com/reference/androidx/collection/ScatterMap) `final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#all(kotlin.Function2)(@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)`

Returns true if all entries match the given `https://developer.android.com/reference/androidx/collection/ScatterMap#all(kotlin.Function2)`.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#any()()`

Returns `true` if this map has at least one entry.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#any(kotlin.Function2)(@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)`

Returns true if at least one entry matches the given `https://developer.android.com/reference/androidx/collection/ScatterMap#any(kotlin.Function2)`.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V>` `https://developer.android.com/reference/androidx/collection/ScatterMap#asMap()()`

Wraps this `https://developer.android.com/reference/androidx/collection/ScatterMap` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html` interface.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#contains(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key)`

Returns true if the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#contains(kotlin.Any)` is present in this hash map, false otherwise.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#containsKey(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key)`

Returns true if the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#containsKey(kotlin.Any)` is present in this hash map, false otherwise.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#containsValue(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull V value)`

Returns true if the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#containsValue(kotlin.Any)` is present in this hash map, false otherwise.
`final int` `https://developer.android.com/reference/androidx/collection/ScatterMap#count()()`

Returns the number of entries in this map.
`final int` `https://developer.android.com/reference/androidx/collection/ScatterMap#count(kotlin.Function2)(@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull K, @https://developer.android.com/reference/androidx/annotation/NonNull V, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Boolean.html> predicate)`

Returns the number of entries matching the given `https://developer.android.com/reference/androidx/collection/ScatterMap#count(kotlin.Function2)`.
`boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)`

Compares the specified object `https://developer.android.com/reference/androidx/collection/ScatterMap#equals(kotlin.Any)` with this hash map for equality.
`final void` `https://developer.android.com/reference/androidx/collection/ScatterMap#forEach(kotlin.Function2)(@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull key, @https://developer.android.com/reference/androidx/annotation/NonNull value, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)`

Iterates over every key/value pair stored in this map by invoking the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#forEach(kotlin.Function2)` lambda.
`final void` `https://developer.android.com/reference/androidx/collection/ScatterMap#forEachKey(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull key, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)`

Iterates over every key stored in this map by invoking the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#forEachKey(kotlin.Function1)` lambda.
`final void` `https://developer.android.com/reference/androidx/collection/ScatterMap#forEachValue(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull value, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)`

Iterates over every value stored in this map by invoking the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#forEachValue(kotlin.Function1)` lambda.
`final V` `https://developer.android.com/reference/androidx/collection/ScatterMap#get(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key)`

Returns the value corresponding to the given `https://developer.android.com/reference/androidx/collection/ScatterMap#get(kotlin.Any)`, or `null` if such a key is not present in the map.
`final int` `https://developer.android.com/reference/androidx/collection/ScatterMap#getCapacity()()`

Returns the number of key-value pairs that can be stored in this map without requiring internal storage reallocation.
`final @https://developer.android.com/reference/androidx/annotation/NonNull V` `https://developer.android.com/reference/androidx/collection/ScatterMap#getOrDefault(kotlin.Any,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull V defaultValue)`

Returns the value to which the specified `https://developer.android.com/reference/androidx/collection/ScatterMap#getOrDefault(kotlin.Any,kotlin.Any)` is mapped, or `https://developer.android.com/reference/androidx/collection/ScatterMap#getOrDefault(kotlin.Any,kotlin.Any)` if this map contains no mapping for the key.
`final @https://developer.android.com/reference/androidx/annotation/NonNull V` `https://developer.android.com/reference/androidx/collection/ScatterMap#getOrElse(kotlin.Any,kotlin.Function0)(@https://developer.android.com/reference/androidx/annotation/NonNull K key, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull V> defaultValue)`

Returns the value for the given `https://developer.android.com/reference/androidx/collection/ScatterMap#getOrElse(kotlin.Any,kotlin.Function0)` if the value is present and not null.
`final int` `https://developer.android.com/reference/androidx/collection/ScatterMap#getSize()()`

Returns the number of key-value pairs in this map.
`int` `https://developer.android.com/reference/androidx/collection/ScatterMap#hashCode()()`

Returns the hash code value for this map.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#isEmpty()()`

Indicates whether this map is empty.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#isNotEmpty()()`

Returns `true` if this map 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/ScatterMap#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function2)(
@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,
Function2<@https://developer.android.com/reference/androidx/annotation/NonNull key, @https://developer.android.com/reference/androidx/annotation/NonNull value, @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/ScatterMap#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function2)` and using `https://developer.android.com/reference/androidx/collection/ScatterMap#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function2)` before and `https://developer.android.com/reference/androidx/collection/ScatterMap#joinToString(kotlin.CharSequence,kotlin.CharSequence,kotlin.CharSequence,kotlin.Int,kotlin.CharSequence,kotlin.Function2)` after, if supplied.
`final boolean` `https://developer.android.com/reference/androidx/collection/ScatterMap#none()()`

Returns `true` if this map has no entries.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/androidx/collection/ScatterMap#toString()()`

Returns a string representation of this map.

## Public constructors

### MutableScatterMap

```
public <K extends Object, V extends Object> MutableScatterMap(int initialCapacity)
```

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

| 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 entries without requiring any allocations. The initial capacity can be set to 0. |

## Public methods

### asMutableMap

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

```
public final @NonNull Map<@NonNull K, @NonNull V> asMutableMap()
```

Wraps this `https://developer.android.com/reference/androidx/collection/ScatterMap` with a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html` interface. The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html` is backed by the `https://developer.android.com/reference/androidx/collection/ScatterMap`, so changes to the `https://developer.android.com/reference/androidx/collection/ScatterMap` are reflected in the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html` and vice-versa. If the `https://developer.android.com/reference/androidx/collection/ScatterMap` is modified while an iteration over the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/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/MutableScatterMap` with APIs accepting `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html` interfaces, it is less efficient to do so than to use `https://developer.android.com/reference/androidx/collection/MutableScatterMap`'s APIs directly. While the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/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-map/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 mappings from this map.

### compute

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

```
public final @NonNull V compute(
    @NonNull K key,
    @NonNull Function2<@NonNull key, value, @NonNull V> computeBlock
)
```

Retrieves a value for `https://developer.android.com/reference/androidx/collection/MutableScatterMap#compute(kotlin.Any,kotlin.Function2)` and computes a new value based on the existing value (or `null` if the key is not in the map). The computed value is then stored in the map for the given `https://developer.android.com/reference/androidx/collection/MutableScatterMap#compute(kotlin.Any,kotlin.Function2)`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull V` | value computed by `computeBlock`. |

### getOrPut

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

```
public final @NonNull V getOrPut(@NonNull K key, @NonNull Function0<@NonNull V> defaultValue)
```

Returns the value to which the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#getOrPut(kotlin.Any,kotlin.Function0)` is mapped, if the value is present in the map and not `null`. Otherwise, calls `defaultValue()` and puts the result in the map associated with `https://developer.android.com/reference/androidx/collection/MutableScatterMap#getOrPut(kotlin.Any,kotlin.Function0)`.

### minusAssign

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

```
public final void minusAssign(@NonNull K key)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.Any)` and its associated value from the map.

### minusAssign

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

```
public final void minusAssign(@NonNull K[] keys)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.Array)` and their associated value from the map.

### minusAssign

```
public final void minusAssign(@NonNull Iterable<@NonNull K> keys)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.collections.Iterable)` and their associated value from the map.

### minusAssign

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

```
public final void minusAssign(@NonNull ObjectList<@NonNull K> keys)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(androidx.collection.ObjectList)` and their associated value from the map.

### minusAssign

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

```
public final void minusAssign(@NonNull ScatterSet<@NonNull K> keys)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(androidx.collection.ScatterSet)` and their associated value from the map.

### minusAssign

```
public final void minusAssign(@NonNull Sequence<@NonNull K> keys)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#minusAssign(kotlin.sequences.Sequence)` and their associated value from the map.

### plusAssign

```
public final void plusAssign(@NonNull Map<@NonNull K, @NonNull V> from)
```

Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.collections.Map)` map into this map.

### plusAssign

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

```
public final void plusAssign(@NonNull ScatterMap<@NonNull K, @NonNull V> from)
```

Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(androidx.collection.ScatterMap)` map into this map.

### plusAssign

```
public final void plusAssign(@NonNull Pair<@NonNull K, @NonNull V> pair)
```

Puts the key/value mapping from the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.Pair)` in this map, using the first element as the key, and the second element as the value.

### plusAssign

```
public final void plusAssign(@NonNull Pair[] pairs)
```

Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.Array)` into this map, using the first component of the pair as the key, and the second component as the value.

### plusAssign

```
public final void plusAssign(@NonNull Iterable<@NonNull Pair<@NonNull K, @NonNull V>> pairs)
```

Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.collections.Iterable)` into this map, using the first component of the pair as the key, and the second component as the value.

### plusAssign

```
public final void plusAssign(@NonNull Sequence<@NonNull Pair<@NonNull K, @NonNull V>> pairs)
```

Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#plusAssign(kotlin.sequences.Sequence)` into this map, using the first component of the pair as the key, and the second component as the value.

### put

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

```
public final V put(@NonNull K key, @NonNull V value)
```

Creates a new mapping from `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)` to `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)` in this map. If `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)` is already present in the map, the association is modified and the previously associated value is replaced with `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)`. If `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)` is not present, a new entry is added to the map, which may require to grow the underlying storage and cause allocations. Return the previous value associated with the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#put(kotlin.Any,kotlin.Any)`, or `null` if the key was not present in the map.

### putAll

```
public final void putAll(@NonNull Map<@NonNull K, @NonNull V> from)
```

Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.collections.Map)` map into this map.

### putAll

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

```
public final void putAll(@NonNull ScatterMap<@NonNull K, @NonNull V> from)
```

Puts all the key/value mappings in the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(androidx.collection.ScatterMap)` map into this map.

### putAll

```
public final void putAll(@NonNull Pair[] pairs)
```

Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.Array)` into this map, using the first component of the pair as the key, and the second component as the value.

### putAll

```
public final void putAll(@NonNull Iterable<@NonNull Pair<@NonNull K, @NonNull V>> pairs)
```

Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.collections.Iterable)` into this map, using the first component of the pair as the key, and the second component as the value.

### putAll

```
public final void putAll(@NonNull Sequence<@NonNull Pair<@NonNull K, @NonNull V>> pairs)
```

Puts all the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#putAll(kotlin.sequences.Sequence)` into this map, using the first component of the pair as the key, and the second component as the value.

### remove

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

```
public final V remove(@NonNull K key)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any)` and its associated value from the map. If the `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any)` was present in the map, this function returns the value that was present before removal.

### remove

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

```
public final boolean remove(@NonNull K key, @NonNull V value)
```

Removes the specified `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any,kotlin.Any)` and its associated value from the map if the associated value equals `https://developer.android.com/reference/androidx/collection/MutableScatterMap#remove(kotlin.Any,kotlin.Any)`. Returns whether the removal happened.

### removeIf

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

```
public final void removeIf(
    @NonNull Function2<@NonNull K, @NonNull V, @NonNull Boolean> predicate
)
```

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

### set

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

```
public final void set(@NonNull K key, @NonNull V value)
```

Creates a new mapping from `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)` to `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)` in this map. If `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)` is already present in the map, the association is modified and the previously associated value is replaced with `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)`. If `https://developer.android.com/reference/androidx/collection/MutableScatterMap#set(kotlin.Any,kotlin.Any)` is not present, a new entry is added to the map, which may require to grow the underlying storage and cause allocations.

### trim

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

```
public final int trim()
```

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

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