Click or drag to resize

MultiValueDictionary<TKey, TValue> Class

Extension to the normal Dictionary. This class can store more than one value for every key. It keeps a HashSet for every Key value. Calling Add with the same Key and multiple values will store each value under the same Key in the Dictionary. Obtaining the values for a Key will return the HashSet with the Values of the Key. It can also merge with other instances of MultiValueDictionary, as long as the TKey and TValue types are equal.
Inheritance Hierarchy
System.Object
  System.Collections.Generic.Dictionary<TKey, HashSet<TValue>>
    SD.Tools.Algorithmia.GeneralDataStructures.MultiValueDictionary<TKey, TValue>

Namespace:  SD.Tools.Algorithmia.GeneralDataStructures
Assembly:  SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.4.0.0 (1.4.19.0711)
Syntax
[SerializableAttribute]
public class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, HashSet<TValue>>

Type Parameters

TKey
The type of the key.
TValue
The type of the value.

The MultiValueDictionary<TKey, TValue> type exposes the following members.

Constructors
  NameDescription
Public methodMultiValueDictionary<TKey, TValue>()
Initializes a new instance of the MultiValueDictionary<TKey, TValue> class.
Public methodMultiValueDictionary<TKey, TValue>(IEqualityComparer<TValue>)
Initializes a new instance of the MultiValueDictionary<TKey, TValue> class.
Protected methodMultiValueDictionary<TKey, TValue>(SerializationInfo, StreamingContext)
Initializes a new instance of the MultiValueDictionary<TKey, TValue> class.
Top
Properties
  NameDescription
Public propertyComparer (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public propertyCount (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public propertyItem
Gets or sets the value associated with the specified key.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public propertyKeys (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public propertyValues (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Top
Methods
  NameDescription
Public methodAdd(TKey, TValue)
Adds the specified key and value to the dictionary.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodAdd(TKey, TValue)
Adds the specified value under the specified key
Public methodAddRange
Adds the range of values under the key specified.
Public methodClear (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodClone
Clones this instance using shallow copy
Public methodContainsKey (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodContainsValue(TValue) (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodContainsValue(TKey, TValue)
Determines whether this dictionary contains the specified value for the specified key
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetObjectData
Gets the object data.
(Overrides Dictionary<TKey, TValue>.GetObjectData(SerializationInfo, StreamingContext).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetValues
Gets the values for the key specified. This method is useful if you want to avoid an exception for key value retrieval and you can't use TryGetValue (e.g. in lambdas)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMerge
Merges the specified multivaluedictionary into this instance.
Public methodOnDeserialization
Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodRemove(TKey) (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Public methodRemove(TKey, TValue)
Removes the specified value for the specified key. It will leave the key in the dictionary.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryGetValue
Gets the value associated with the specified key.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICollection<KeyValuePair<TKey, TValue>>.Add (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodIDictionary.Add
Adds the specified key and value to the dictionary.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodICollection<KeyValuePair<TKey, TValue>>.Contains (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodIDictionary.Contains
Determines whether the IDictionary contains an element with the specified key.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodICollection<KeyValuePair<TKey, TValue>>.CopyTo (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodICollection.CopyTo (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodIEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodIEnumerable.GetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodIDictionary.GetEnumerator (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary.IsFixedSize
Gets a value indicating whether the IDictionary has a fixed size.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
Gets a value indicating whether the dictionary is read-only.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary.IsReadOnly
Gets a value indicating whether the IDictionary is read-only.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyICollection.IsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary.Item
Gets or sets the value with the specified key.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary<TKey, TValue>.Keys (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIReadOnlyDictionary<TKey, TValue>.Keys (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary.Keys
Gets an ICollection containing the keys of the IDictionary.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodICollection<KeyValuePair<TKey, TValue>>.Remove
Removes a key and value from the dictionary.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate methodIDictionary.Remove
Removes the element with the specified key from the IDictionary.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyICollection.SyncRoot
Gets an object that can be used to synchronize access to the ICollection.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary<TKey, TValue>.Values (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIReadOnlyDictionary<TKey, TValue>.Values (Inherited from Dictionary<TKey, HashSet<TValue>>.)
Explicit interface implementationPrivate propertyIDictionary.Values
Gets an ICollection containing the values in the IDictionary.
(Inherited from Dictionary<TKey, HashSet<TValue>>.)
Top
See Also