Class DictionaryExtensions
- Namespace
- LfrlAnvil.Functional.Extensions
- Assembly
- LfrlAnvil.Functional.dll
Contains dictionary extension methods.
public static class DictionaryExtensions
- Inheritance
-
DictionaryExtensions
- Inherited Members
Methods
TryGetValue<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>, TKey)
Attempts to get a value associated with the provided key
from the dictionary
.
[Pure]
public static Maybe<TValue> TryGetValue<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) where TValue : notnull
Parameters
dictionary
IReadOnlyDictionary<TKey, TValue>Source dictionary.
key
TKeyEntry's key.
Returns
- Maybe<TValue>
New Maybe<T> instance equivalent to value associated with the provided
key
or None when it does not exist.
Type Parameters
TKey
Key type.
TValue
Value type.
TryRemove<TKey, TValue>(Dictionary<TKey, TValue>, TKey)
Attempts to get remove an entry associated with the provided key
from the dictionary
.
[Pure]
public static Maybe<TValue> TryRemove<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull where TValue : notnull
Parameters
dictionary
Dictionary<TKey, TValue>Source dictionary.
key
TKeyEntry's key.
Returns
- Maybe<TValue>
New Maybe<T> instance equivalent to removed value associated with the provided
key
or None when it does not exist.
Type Parameters
TKey
Key type.
TValue
Value type.