SuspendMutableMap

interface SuspendMutableMap<K, V>

A mutable map with suspendable, non-blocking operations, designed for asynchronous access in coroutine-based environments. This interface mirrors the standard MutableMap, but its functions are suspendable to allow for implementations that perform I/O, network requests, or other long-running tasks without blocking a thread.

Implementations of this interface are expected to be safe for concurrent use.

Parameters

K

The type of keys maintained by this map.

V

The type of mapped values.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun clear()

Removes all of the mappings from this map. The map will be empty after this call returns. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun containsKey(key: K): Boolean

Checks if this map contains a mapping for the specified key. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun entries(): Set<Map.Entry<K, V>>

Returns a read-only Set of all key-value pairs in this map. The returned set may be a snapshot or a live view, depending on the implementation. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun get(key: K): V?

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun isEmpty(): Boolean

Checks if this map contains no key-value mappings. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun keys(): Set<K>

Returns a read-only Set of all keys in this map. The returned set may be a snapshot or a live view, depending on the implementation. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun put(key: K, value: V): V?

Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun putAll(from: Map<out K, V>)

Copies all of the mappings from the specified map from to this map. These mappings will replace any mappings that this map had for any of the keys that are currently in the specified map. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun remove(key: K): V?

Removes the mapping for a key from this map if it is present. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun size(): Int

Returns the number of key-value mappings in this map. This is a suspendable, non-blocking operation.

Link copied to clipboard
abstract suspend fun values(): Collection<V>

Returns a read-only Collection of all values in this map. The returned collection may be a snapshot or a live view, depending on the implementation. This is a suspendable, non-blocking operation.