SynchronizedSet

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

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

Parameters

E

The type of elements contained in the set.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val size: Int

Returns the number of elements in the set. This operation is synchronized.

Functions

Link copied to clipboard
open override fun add(element: E): Boolean

Adds the specified element to the set if it is not already present. This operation is synchronized.

Link copied to clipboard
open override fun addAll(elements: Collection<E>): Boolean

Adds all elements in the specified collection to the set. This operation is synchronized.

Link copied to clipboard
open override fun clear()

Removes all elements from the set. This operation is synchronized.

Link copied to clipboard
open operator override fun contains(element: E): Boolean

Returns true if the set contains the specified element. This operation is synchronized.

Link copied to clipboard
open override fun containsAll(elements: Collection<E>): Boolean

Returns true if the set contains all elements in the specified collection. This operation is synchronized.

Link copied to clipboard

Creates a shallow copy of the current SynchronizedSet.

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

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

Link copied to clipboard
open operator override fun iterator(): MutableIterator<E>

Returns an iterator over the elements in the set. This operation is synchronized.

Link copied to clipboard
open override fun remove(element: E): Boolean

Removes the specified element from the set if it is present. This operation is synchronized.

Link copied to clipboard
open override fun removeAll(elements: Collection<E>): Boolean

Removes all elements in the specified collection from the set. This operation is synchronized.

Link copied to clipboard
open override fun retainAll(elements: Collection<E>): Boolean

Retains only the elements in the set that are contained in the specified collection. This operation is synchronized.