Class DictionaryUtil
- Namespace
- Hi.Common.Collections
- Assembly
- HiGeom.dll
Utility class providing extension methods for dictionary operations.
public static class DictionaryUtil
- Inheritance
-
DictionaryUtil
- Inherited Members
Methods
Retrieve<K, V>(Dictionary<K, V>, K, out V, bool)
Retrieves a value from a dictionary by key, with an option to remove it from the source.
public static bool Retrieve<K, V>(this Dictionary<K, V> src, K key, out V v, bool removeFromSource)
Parameters
srcDictionary<K, V>The source dictionary.
keyKThe key to look for.
vVWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter.
removeFromSourceboolIf true, removes the key-value pair from the dictionary if found.
Returns
- bool
true if the key was found; otherwise, false.
Type Parameters
KThe type of the keys in the dictionary.
VThe type of the values in the dictionary.
TryGetValueByKeys<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<TKey>, out TValue)
Tries to get a value from a dictionary by checking multiple keys in sequence.
public static bool TryGetValueByKeys<TKey, TValue>(this IDictionary<TKey, TValue> src, IEnumerable<TKey> keys, out TValue v)
Parameters
srcIDictionary<TKey, TValue>The source dictionary.
keysIEnumerable<TKey>The collection of keys to check.
vTValueWhen this method returns, contains the value associated with the first matching key, if a key is found; otherwise, the default value for the type of the value parameter.
Returns
- bool
true if any of the keys was found; otherwise, false.
Type Parameters
TKeyThe type of the keys in the dictionary.
TValueThe type of the values in the dictionary.