AtomicSet

class AtomicSet<E> : Set<E>

A Set that allows for thread safe, atomic mutation. Returned iterator references a snapshot of when this was accessed, and is not mutated when the set is.

Although mutable, this class intentionally does not implement MutableSet. Mutation must use designated mutator functions (mutate, snapshotAndMutate, mutateAndSnapshot).

Constructors

Link copied to clipboard
constructor(initial: PersistentSet<E>)

Construct an AtomicSet with initial set.

Properties

Link copied to clipboard
open override val size: Int
Link copied to clipboard
val snapshot: ImmutableSet<E>

Returns the current value of this set as an immutable snapshot.

Link copied to clipboard
val snapshots: StateFlow<ImmutableSet<E>>

Returns this set as a StateFlow. Each mutation will cause a new emission on this flow.

Functions

Link copied to clipboard
open operator override fun contains(element: E): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<E>): Boolean
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<E>
Link copied to clipboard
inline fun mutate(mutator: MutableSet<E>.() -> Unit)

Mutates this set atomically. mutator can be evaluated multiple times if a concurrent edit occurs.

Link copied to clipboard
inline fun mutateAndSnapshot(mutator: MutableSet<E>.() -> Unit): ImmutableSet<E>

Mutates this set atomically and returns the new snapshot. mutator can be evaluated multiple times if a concurrent edit occurs.

Link copied to clipboard
inline fun snapshotAndMutate(mutator: MutableSet<E>.() -> Unit): ImmutableSet<E>

Mutates this set atomically and returns the previous snapshot. mutator can be evaluated multiple times if a concurrent edit occurs.

Link copied to clipboard
open override fun toString(): String