Class MultiDictionary<TKey, TValue>
- Namespace
 - NanoByte.Common.Collections
 
- Assembly
 - NanoByte.Common.dll
 
A dictionary that allows a key to reference multiple values.
[Serializable]
public class MultiDictionary<TKey, TValue> : Dictionary<TKey, HashSet<TValue>> where TKey : notnull
  Type Parameters
TKeyThe type to use as a key to identify entries in the dictionary.
TValueThe type to use as elements to store in the dictionary.
- Inheritance
 - 
      objectDictionary<TKey, HashSet<TValue>>MultiDictionary<TKey, TValue>
 
- Extension Methods
 
Remarks
This structure internally uses hash maps, so most operations run in O(1).
Properties
this[TKey]
Gets a collection containing the values with the specified key.
[CollectionAccess(CollectionAccessType.Read)]
public IEnumerable<TValue> this[TKey key] { get; }
  Parameters
keyTKeyThe key of the element to get.
Property Value
- IEnumerable<TValue>
 A list of elements with the specified key. Empty list if the key was not found.
Values
A collection containing the values in the dictionary.
[CollectionAccess(CollectionAccessType.Read)]
public IEnumerable<TValue> Values { get; }
  Property Value
- IEnumerable<TValue>
 
Methods
Add(TKey, TValue)
Adds an element with the provided key and value to the dictionary.
[CollectionAccess(CollectionAccessType.UpdatedContent)]
public void Add(TKey key, TValue value)
  Parameters
keyTKeyThe key of the element to add.
valueTValueThe value of the element to add.
Remove(TKey, TValue)
Removes an element with the provided key and value from the dictionary.
[CollectionAccess(CollectionAccessType.ModifyExistingContent)]
public bool Remove(TKey key, TValue value)
  Parameters
keyTKeyThe key of the element to remove.
valueTValueThe value of the element to remove.
Returns
- bool
 trueif any elements were successfully removed; otherwise,false.