SynchronizedMap

A thread-safe implementation of a mutable map. This class provides synchronization to ensure that all operations on the map are thread-safe.

This class uses an internal lock (SynchronizedObject) to synchronize access to the underlying mutable map (delegate). All methods are synchronized to prevent concurrent modification issues.

Parameters

K

The type of keys maintained by the map.

V

The type of values associated with the keys.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Returns a set of key-value pairs contained in the map. This operation is synchronized.

Link copied to clipboard
open override val keys: MutableSet<K>

Returns a set of keys contained in the map. This operation is synchronized.

Link copied to clipboard
open override val size: Int

Returns the number of key-value pairs in the map. This operation is synchronized.

Link copied to clipboard
open override val values: MutableCollection<V>

Returns a collection of values contained in the map. This operation is synchronized.

Functions

Link copied to clipboard
open override fun clear()

Removes all mappings from the map. This operation is synchronized.

Link copied to clipboard
open override fun containsKey(key: K): Boolean

Returns true if the map contains the specified key. This operation is synchronized.

Link copied to clipboard
open override fun containsValue(value: V): Boolean

Returns true if the map contains the specified value. This operation is synchronized.

Link copied to clipboard

Creates a shallow copy of the current SynchronizedMap.

Link copied to clipboard
open operator override fun get(key: K): V?

Returns the value associated with the specified key, or null if the map contains no mapping for the key. This operation is synchronized.

Link copied to clipboard
open override fun isEmpty(): Boolean

Returns true if the map is empty. This operation is synchronized.

Link copied to clipboard
open override fun put(key: K, value: V): V?

Associates the specified value with the specified key in the map. This operation is synchronized.

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

Copies all of the mappings from the specified map to this map. This operation is synchronized.

Link copied to clipboard
open override fun remove(key: K): V?

Removes the mapping for the specified key from the map if present. This operation is synchronized.