MultiDictionary<TKey, TValue>
Provides a palette with multiple values per key. This class is not optimized for large overlaps of values.
Type parameters:
| TKey | Key type. |
| TValue | Value type. |
Constructors
MultiDictionary
#Create a new MultiDictionary with a specific comparer.
Parameters:
| comparer (IEqualityComparer<TKey>) | Equality comparer for keys. |
MultiDictionary
#Create a new MultiDictionary with a specific comparer.
Parameters:
| capacity (int) | Initial capacity. |
| comparer (IEqualityComparer<TKey>) | Equality comparer for keys. |
Properties
Indexers
this[]
#Gets all items associated with a specific key.
Parameters:
| key (TKey) | Key to retrieve. |
Returns: Enumerable collection of items.
Methods
AddRange
#Add values to this MultiDictionary.
Parameters:
| key (TKey) | Key. |
| values (IEnumerable<TValue>) | Value. |
ContainsKey
#Test whether a specific key is defined.
Parameters:
| key (TKey) | Key to test. |
Returns: True if key has been defined.
KeyValence
#Gets the number of values associated with the given key.
Parameters:
| key (TKey) | Key to test. |
Returns: Number of items associated with key.
Remove
#Remove a specific value associated with a specific key.
Parameters:
| key (TKey) | Key associated with value. |
| value (TValue) | Value to remove. |
RemoveAll
#Remove all occurences of a specific value.
Parameters:
| value (TValue) | Value to remove. |
Returns: Number of instances removed.
RemoveListsByLength
#Remove all entries that contain lists shorter than or longer than the specified limits.
TryGetAll
#public TValue[] TryGetAll(TKey key)
Try to get all values associated with a specific key.
Parameters:
| key (TKey) | Key. |
Returns: Array of values associated with key.
TryGetFirst
#Try to get the get the first value associated with a specific key.
Parameters:
| key (TKey) | Key. |
| value (out TValue) | First value associated with key. |
Returns: True if a first value was found.
TryGetOne
#Try to get a single value associated with the key. If the key has valence zero or higher than one, this method will return false.
Parameters:
| key (TKey) | Key to search for. |
| value (out TValue) | Single value will be returned here. |
Returns: True on success, false on failure.