Show / Hide Table of Contents

Class MultiDictionary<TKey, TValue>

A dictionary that allows a key to reference multiple values.

Inheritance
Object
MultiDictionary<TKey, TValue>
Namespace: NanoByte.Common.Collections
Assembly: NanoByte.Common.dll
Syntax
public class MultiDictionary<TKey, TValue> : Dictionary<TKey, HashSet<TValue>>
Type Parameters
Name Description
TKey

The type to use as a key to identify entries in the dictionary.

TValue

The type to use as elements to store in the dictionary.

Remarks

This structure internally uses hash maps, so most operations run in O(1).

Constructors

MultiDictionary()

Declaration
public MultiDictionary()

Properties

Item[TKey]

Gets a collection containing the values with the specified key.

Declaration
public IEnumerable<TValue> this[TKey key] { get; }
Parameters
Type Name Description
TKey key

The key of the element to get.

Property Value
Type Description
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.

Declaration
public IEnumerable<TValue> Values { get; }
Property Value
Type Description
IEnumerable<TValue>

Methods

Add(TKey, TValue)

Adds an element with the provided key and value to the dictionary.

Declaration
public void Add(TKey key, TValue value)
Parameters
Type Name Description
TKey key

The key of the element to add.

TValue value

The value of the element to add.

Remove(TKey, TValue)

Removes an element with the provided key and value from the dictionary.

Declaration
public bool Remove(TKey key, TValue value)
Parameters
Type Name Description
TKey key

The key of the element to remove.

TValue value

The value of the element to remove.

Returns
Type Description
Boolean

true if any elements were successfully removed; otherwise, false.

Extension Methods

UpdateUtils.To<TIn, TOut>(TIn, Func<TIn, TOut>)
JsonStorage.SaveJson<T>(T, Stream)
JsonStorage.SaveJson<T>(T, String)
JsonStorage.ToJsonString<T>(T)
JsonStorage.ReparseAsJson<T>(Object)
JsonStorage.ReparseAsJson<T>(Object, T)
XmlStorage.SaveXml(Object, Stream, String)
XmlStorage.SaveXml<T>(T, String, String)
XmlStorage.ToXmlString(Object, String)
ConversionUtils.ConvertToString<TType>(TType)
In This Article
Back to top Copyright Bastian Eicher