DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="1.2.0" />

 Dictionary

public static class Dictionary
Represents various extensions for types Dictionary<T, U> and IDictionary<T, U>.
public static class Indexer<K, V>

Provides strongly-typed access to dictionary indexer.

public static ReadOnlyDictionaryView<K, V, T> ConvertValues<K, V, T>(this IReadOnlyDictionary<K, V> dictionary, ref ValueFunc mapper)

Applies lazy conversion for each dictionary value.

public static ReadOnlyDictionaryView<K, V, T> ConvertValues<K, V, T>(this IReadOnlyDictionary<K, V> dictionary, Converter<V, T> mapper)

Applies lazy conversion for each dictionary value.

public static void Deconstruct<K, V>(this KeyValuePair<K, V> pair, out K key, out V value)

Deconstruct key/value pair.

public static void ForEach<K, V>(this IDictionary<K, V> dictionary, ref ValueAction action)

Applies specific action to each dictionary

public static void ForEach<K, V>(this IDictionary<K, V> dictionary, Action<K, V> action)

Applies specific action to each dictionary

public static V GetOrAdd<K, V>(this Dictionary<K, V> dictionary, K key)

Adds a key-value pair to the dictionary if the key does not exist.

public static V GetOrAdd<K, V>(this Dictionary<K, V> dictionary, K key, V value)

Adds a key-value pair to the dictionary if the key does not exist.

public static V GetOrAdd<K, V>(this Dictionary<K, V> dictionary, K key, ref ValueFunc valueFactory)

Generates a value and adds the key-value pair to the dictionary if the key does not exist.

public static V GetOrAdd<K, V>(this Dictionary<K, V> dictionary, K key, Func<K, V> valueFactory)

Generates a value and adds the key-value pair to the dictionary if the key does not exist.

public static V GetOrInvoke<K, V>(this IDictionary<K, V> dictionary, K key, ref ValueFunc defaultValue)

Gets dictionary value by key if it exists or invoke defaultValue and return its result as a default value.

public static V GetOrInvoke<K, V>(this IDictionary<K, V> dictionary, K key, Func<V> defaultValue)

Gets dictionary value by key if it exists or invoke defaultValue and return its result as a default value.

public static Func<K, V> IndexerGetter<K, V>(this IReadOnlyDictionary<K, V> dictionary)

Returns get_Item as delegate attached to the dictionary instance.

public static Func<K, V> IndexerGetter<K, V>(this IDictionary<K, V> dictionary)

Returns get_Item as delegate attached to the dictionary instance.

public static Action<K, V> IndexerSetter<K, V>(this IDictionary<K, V> dictionary)

Returns set_Item as delegate attached to the dictionary instance.

public static Optional<V> TryGetValue<K, V>(this IDictionary<K, V> dictionary, K key)

Gets the value associated with the specified key.

public static Optional<V> TryGetValue<K, V>(IReadOnlyDictionary<K, V> dictionary, K key)

Gets the value associated with the specified key.

public static Optional<V> TryRemove<K, V>(this IDictionary<K, V> dictionary, K key)

Removes the value with the specified key and return the removed value.