Table of Contents

Class MultiValueSortedDictionary<TKey, TValue>

Namespace
Stride.Core.Collections
Assembly
Stride.Core.dll

Represents a priority queue, where keys are sorted and each key might have mlutiple values.

public class MultiValueSortedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable

Type Parameters

TKey

The type of the key.

TValue

The type of the value.

Inheritance
MultiValueSortedDictionary<TKey, TValue>
Implements
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
IEnumerable<KeyValuePair<TKey, TValue>>
Extension Methods

Remarks

Storage is based on a SortedDictionary<TKey, TValue>.

Constructors

MultiValueSortedDictionary()

Initializes a new instance of the KoderHack.MultiValueSortedDictionary<TKey,TValue> class that is empty and uses the default System.Collections.Generic.IComparer<TKey> implementation to compare keys.

public MultiValueSortedDictionary()

MultiValueSortedDictionary(IComparer<TKey>)

Initializes a new instance of the KoderHack.MultiValueSortedDictionary<TKey,TValue> class that is empty and uses the specified System.Collections.Generic.IComparer<TKey> implementation to compare keys.

public MultiValueSortedDictionary(IComparer<TKey> comparer)

Parameters

comparer IComparer<TKey>

The System.Collections.Generic.IComparer<TKey> implementation to use when comparing keys, or null to use the default System.Collections.Generic.Comparer<TKey> for the type of the key.

MultiValueSortedDictionary(IDictionary<TKey, TValue>)

Initializes a new instance of the KoderHack.MultiValueSortedDictionary<TKey,TValue> class that contains elements copied from the specified System.Collections.Generic.IDictionary<TKey,TValue> and uses the default System.Collections.Generic.IComparer<T> implementation for the key type.

public MultiValueSortedDictionary(IDictionary<TKey, TValue> dictionary)

Parameters

dictionary IDictionary<TKey, TValue>

The System.Collections.Generic.IDictionary<TKey,TValue> whose elements are copied to the new KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Exceptions

ArgumentNullException

dictionary is null

MultiValueSortedDictionary(IDictionary<TKey, TValue>, IComparer<TKey>)

Initializes a new instance of the KoderHack.MultiValueSortedDictionary<TKey,TValue> class that contains elements copied from the specified System.Collections.Generic.IDictionary<TKey,TValue> and uses the specified System.Collections.Generic.IComparer<TKey> implementation to compare keys.

public MultiValueSortedDictionary(IDictionary<TKey, TValue> dictionary, IComparer<TKey> comparer)

Parameters

dictionary IDictionary<TKey, TValue>

The System.Collections.Generic.IDictionary<TKey,TValue> whose elements are copied to the new KoderHack.MultiValueSortedDictionary<TKey,TValue>.

comparer IComparer<TKey>

The System.Collections.Generic.IComparer<T> implementation to use when comparing keys, or null to use the default System.Collections.Generic.Comparer<TKey> for the type of the key.

Exceptions

ArgumentNullException

dictionary is null

Properties

Comparer

Gets the System.Collections.Generic.IComparer<TKey> used to order the elements of the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public IComparer<TKey> Comparer { get; }

Property Value

IComparer<TKey>

The System.Collections.Generic.IComparer<TKey> used to order the elements of the KoderHack.MultiValueSortedDictionary<TKey,TValue>

Count

Gets the number of key/value pairs contained in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public int Count { get; }

Property Value

int

The number of key/value pairs contained in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

this[TKey]

Gets or sets the value associated with the specified key.

public TValue this[TKey key] { get; set; }

Parameters

key TKey

The key of the value to get or set.

Property Value

TValue

The value associated with the specified key. If the specified key is not found, a get operation throws a System.Collections.Generic.KeyNotFoundException, and a set operation creates a new element with the specified key.

Exceptions

ArgumentNullException

key is null.

KeyNotFoundException

The property is retrieved and key does not exist in the collection.

Keys

Gets a collection containing the keys in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public SortedDictionary<TKey, List<TValue>>.KeyCollection Keys { get; }

Property Value

SortedDictionary<TKey, List<TValue>>.KeyCollection

A KoderHack.MultiValueSortedDictionary<TKey,TValue>.KeyCollection containing the keys in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Values

Gets a collection containing the values in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public MultiValueSortedDictionary<TKey, TValue>.ValueCollection Values { get; }

Property Value

MultiValueSortedDictionary<TKey, TValue>.ValueCollection

A KoderHack.MultiValueSortedDictionary<TKey,TValue>.ValueCollection containing the keys in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Methods

Add(TKey, TValue)

Adds an element with the specified key and value into the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public void Add(TKey key, TValue value)

Parameters

key TKey

The key of the element to add.

value TValue

The value of the element to add. The value can be null for reference types.

Exceptions

ArgumentNullException

key is null.

Clear()

Removes all elements from the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public void Clear()

ContainsKey(TKey)

Determines whether the KoderHack.MultiValueSortedDictionary<TKey,TValue> contains an element with the specified key.

public bool ContainsKey(TKey key)

Parameters

key TKey

The key to locate in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Returns

bool

true if the KoderHack.MultiValueSortedDictionary<TKey,TValue> contains an element with the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

ContainsValue(TValue)

Determines whether the KoderHack.MultiValueSortedDictionary<TKey,TValue> contains an element with the specified value.

public bool ContainsValue(TValue value)

Parameters

value TValue

The value to locate in the KoderHack.MultiValueSortedDictionary<TKey,TValue>. The value can be null for reference types.

Returns

bool

true if the KoderHack.MultiValueSortedDictionary<TKey,TValue> contains an element with the specified value; otherwise, false.

CopyTo(KeyValuePair<TKey, TValue>[], int)

Copies the elements of the KoderHack.MultiValueSortedDictionary<TKey,TValue> to the specified array of KeyValuePair<TKey, TValue> structures, starting at the specified index.

public void CopyTo(KeyValuePair<TKey, TValue>[] array, int index)

Parameters

array KeyValuePair<TKey, TValue>[]

The one-dimensional array of KeyValuePair<TKey, TValue> structures that is the destination of the elements copied from the current KoderHack.MultiValueSortedDictionary<TKey,TValue> The array must have zero-based indexing.

index int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

index is equal to or greater than the length of array. -or- index is less than 0.

ArgumentException

The number of elements in the source KoderHack.MultiValueSortedDictionary<TKey,TValue> is greater than the available space from index to the end of the destination array.

GetEnumerator()

Returns an enumerator that iterates through the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public MultiValueSortedDictionary<TKey, TValue>.Enumerator GetEnumerator()

Returns

MultiValueSortedDictionary<TKey, TValue>.Enumerator

A KoderHack.MultiValueSortedDictionary<TKey,TValue>.Enumerator for the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Remove(KeyValuePair<TKey, TValue>)

Removes the element with the specified key from the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public bool Remove(KeyValuePair<TKey, TValue> item)

Parameters

item KeyValuePair<TKey, TValue>

The key of the element to remove.

Returns

bool

true if the element is successfully removed; otherwise, false. This method also returns false if key is not found in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Exceptions

ArgumentNullException

key is null.

Remove(TKey)

Removes the elements with the specified key from the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

public bool Remove(TKey key)

Parameters

key TKey

The key of the element to remove.

Returns

bool

true if the element is successfully removed; otherwise, false. This method also returns false if key is not found in the KoderHack.MultiValueSortedDictionary<TKey,TValue>.

Exceptions

ArgumentNullException

key is null.

TryGetValue(TKey, out IEnumerable<TValue>)

Gets the value associated with the specified key.

public bool TryGetValue(TKey key, out IEnumerable<TValue> values)

Parameters

key TKey

The key of the value to get.

values IEnumerable<TValue>

When this method returns, the values associated with the specified key, if the key is found; otherwise null.

Returns

bool

true if the KoderHack.MultiValueSortedDictionary<TKey,TValue> contains an element with the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

TryGetValue(TKey, out TValue)

Gets the value associated with the specified key.

public bool TryGetValue(TKey key, out TValue value)

Parameters

key TKey

The key of the value to get.

value TValue

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter.

Returns

bool

true if the KoderHack.MultiValueSortedDictionary<TKey,TValue> contains an element with the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

TryToGetOnNotFound(TKey)

protected virtual object TryToGetOnNotFound(TKey name)

Parameters

name TKey

Returns

object