System.Collections.Immutable by Microsoft

<PackageReference Include="System.Collections.Immutable" Version="5.0.0-preview.4.20251.6" />

.NET API 188,792 bytes

 ImmutableInterlocked

public static class ImmutableInterlocked
Contains interlocked exchange mechanisms for immutable collections. NuGet package: System.Collections.Immutable (about immutable collections and how to install)
public static TValue AddOrUpdate<TKey, TValue>(ref ImmutableDictionary location, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)

Obtains the value from a dictionary after having added it or updated an existing entry.

public static TValue AddOrUpdate<TKey, TValue>(ref ImmutableDictionary location, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)

Obtains the value from a dictionary after having added it or updated an existing entry.

public static void Enqueue<T>(ref ImmutableQueue location, T value)

Atomically enqueues an element to the end of a queue.

public static TValue GetOrAdd<TKey, TValue, TArg>(ref ImmutableDictionary location, TKey key, Func<TKey, TArg, TValue> valueFactory, TArg factoryArgument)

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

public static TValue GetOrAdd<TKey, TValue>(ref ImmutableDictionary location, TKey key, Func<TKey, TValue> valueFactory)

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

public static TValue GetOrAdd<TKey, TValue>(ref ImmutableDictionary location, TKey key, TValue value)

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

public static ImmutableArray<T> InterlockedCompareExchange<T>(ref ImmutableArray location, ImmutableArray<T> value, ImmutableArray<T> comparand)

Compares two immutable arrays for equality and, if they are equal, replaces one of the arrays.

public static ImmutableArray<T> InterlockedExchange<T>(ref ImmutableArray location, ImmutableArray<T> value)

Sets an array to the specified array and returns a reference to the original array, as an atomic operation.

public static bool InterlockedInitialize<T>(ref ImmutableArray location, ImmutableArray<T> value)

Sets an array to the specified array if the array has not been initialized.

public static void Push<T>(ref ImmutableStack location, T value)

Pushes a new element onto the stack.

public static bool TryAdd<TKey, TValue>(ref ImmutableDictionary location, TKey key, TValue value)

Adds the specified key and value to the dictionary if the key is not in the dictionary.

public static bool TryDequeue<T>(ref ImmutableQueue location, out T value)

Atomically removes and returns the specified element at the head of the queue, if the queue is not empty.

public static bool TryPop<T>(ref ImmutableStack location, out T value)

Removes an element from the top of the stack, if there is an element to remove.

public static bool TryRemove<TKey, TValue>(ref ImmutableDictionary location, TKey key, out TValue value)

Removes the element with the specified key, if the key exists.

public static bool TryUpdate<TKey, TValue>(ref ImmutableDictionary location, TKey key, TValue newValue, TValue comparisonValue)

Sets the specified key to the specified value if the specified key already is set to a specific value.

public static bool Update<T>(ref T location, Func<T, T> transformer)

Mutates a value in-place with optimistic locking transaction semantics via a specified transformation function. The transformation is retried as many times as necessary to win the optimistic locking race.

public static bool Update<T, TArg>(ref T location, Func<T, TArg, T> transformer, TArg transformerArgument)

Mutates a value in-place with optimistic locking transaction semantics via a specified transformation function. The transformation is retried as many times as necessary to win the optimistic locking race.

public static bool Update<T>(ref ImmutableArray location, Func<ImmutableArray<T>, ImmutableArray<T>> transformer)

public static bool Update<T, TArg>(ref ImmutableArray location, Func<ImmutableArray<T>, TArg, ImmutableArray<T>> transformer, TArg transformerArgument)