System.Collections.Immutable by Microsoft

<PackageReference Include="System.Collections.Immutable" Version="8.0.0-preview.1.23110.8" />

.NET API 249,008 bytes

 ImmutableDictionary<TKey, TValue>

public sealed class ImmutableDictionary<TKey, TValue> : IImmutableDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IImmutableDictionaryInternal<TKey, TValue>, IHashKeyCollection<TKey>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IDictionary, ICollection
Represents an immutable, unordered collection of keys and values. NuGet package: System.Collections.Immutable (about immutable collections and how to install)
public sealed class Builder<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IDictionary, ICollection

Represents a hash map that mutates with little or no memory allocations and that can produce or build on immutable hash map instances very efficiently. NuGet package: System.Collections.Immutable (about immutable collections and how to install)

public struct Enumerator<TKey, TValue> : IEnumerator<KeyValuePair<TKey, TValue>>, IEnumerator, IDisposable

Enumerates the contents of the immutable dictionary without allocating any memory. NuGet package: System.Collections.Immutable (about immutable collections and how to install)

public static readonly ImmutableDictionary<TKey, TValue> Empty

Gets an empty immutable dictionary.

public int Count { get; }

Gets the number of key/value pairs in the immutable dictionary.

public bool IsEmpty { get; }

Gets a value that indicates whether this instance of the immutable dictionary is empty.

public TValue this[TKey key] { get; }

Gets the TValue associated with the specified key.

public IEqualityComparer<TKey> KeyComparer { get; }

Gets the key comparer for the immutable dictionary.

public IEnumerable<TKey> Keys { get; }

Gets the keys in the immutable dictionary.

public IEqualityComparer<TValue> ValueComparer { get; }

Gets the value comparer used to determine whether values are equal.

public IEnumerable<TValue> Values { get; }

Gets the values in the immutable dictionary.

public ImmutableDictionary<TKey, TValue> Add(TKey key, TValue value)

Adds an element with the specified key and value to the immutable dictionary.

public ImmutableDictionary<TKey, TValue> AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs)

Adds the specified key/value pairs to the immutable dictionary.

public ImmutableDictionary<TKey, TValue> Clear()

Retrieves an empty immutable dictionary that has the same ordering and key/value comparison rules as this dictionary instance.

public bool Contains(KeyValuePair<TKey, TValue> pair)

Determines whether this immutable dictionary contains the specified key/value pair.

public bool ContainsKey(TKey key)

Determines whether the immutable dictionary contains an element with the specified key.

public bool ContainsValue(TValue value)

Determines whether the immutable dictionary contains an element with the specified value.

public Enumerator<TKey, TValue> GetEnumerator()

Returns an enumerator that iterates through the immutable dictionary.

public ImmutableDictionary<TKey, TValue> Remove(TKey key)

Removes the element with the specified key from the immutable dictionary.

public ImmutableDictionary<TKey, TValue> RemoveRange(IEnumerable<TKey> keys)

Removes the elements with the specified keys from the immutable dictionary.

public ImmutableDictionary<TKey, TValue> SetItem(TKey key, TValue value)

Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key.

public ImmutableDictionary<TKey, TValue> SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items)

Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys.

public Builder<TKey, TValue> ToBuilder()

Creates an immutable dictionary with the same contents as this dictionary that can be efficiently mutated across multiple operations by using standard mutable interfaces.

public bool TryGetKey(TKey equalKey, out TKey actualKey)

Determines whether this dictionary contains a specified key.

public bool TryGetValue(TKey key, out TValue value)

Gets the value associated with the specified key.

public ImmutableDictionary<TKey, TValue> WithComparers(IEqualityComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer)

Gets an instance of the immutable dictionary that uses the specified key and value comparers.

public ImmutableDictionary<TKey, TValue> WithComparers(IEqualityComparer<TKey> keyComparer)

Gets an instance of the immutable dictionary that uses the specified key comparer.