MultiDictionary<TKey, TValue>

public class MultiDictionary<TKey, TValue>
Provides a palette with multiple values per key. This class is not optimized for large overlaps of values.
TKeyKey type.
TValueValue type.

Constructors

MultiDictionary

#
Create a new MultiDictionary.
public MultiDictionary()

MultiDictionary

#
Create a new MultiDictionary with a specific comparer.
public MultiDictionary(
comparer
Equality comparer for keys.
)

MultiDictionary

#
Create a new MultiDictionary with a specific comparer.
public MultiDictionary(
capacity,
Initial capacity.
comparer
Equality comparer for keys.
)

MultiDictionary

#
Create a new MultiDictionary with a specific capacity.
public MultiDictionary(
capacity
Initial capacity.
)

Properties

ArrayPairs

#
Gets an enumerator for all key/valuearray pairs.
public IEnumerable<KeyValuePair<TKey, TValue[]>> ArrayPairs { get; }

HighestValence

#
Gets the highest valence in this MultiDictionary.
public int HighestValence { get; }

KeyCount

#
Gets the number of keys stored in this MultiDictionary.
public int KeyCount { get; }

Keys

#
Enumerate over all keys.
public IEnumerable<TKey> Keys { get; }

LowestValence

#
Gets the lowest valence in this MultiDictionary.
public int LowestValence { get; }

ValueArrays

#
Enumerate over all value arrays.
public IEnumerable<TValue[]> ValueArrays { get; }

ValueCount

#
Gets the number of values stored in this MultiDictionary.
public int ValueCount { get; }

Values

#
Enumerate over all values.
public IEnumerable<TValue> Values { get; }

Indexers

this[]

#
Gets all items associated with a specific key.
public IEnumerable<TValue> this[
TKey
key
Key to retrieve.
] { get; }
Enumerable collection of items.

Methods

Add

#
Add a value to this MultiDictionary.
public MultiDictionaryAddition Add(
TKey
key,
Key.
TValue
value
Value.
)

AddRange

#
Add values to this MultiDictionary.
public MultiDictionaryAddition AddRange(
TKey
key,
Key.
IEnumerable<TValue>
values
Value.
)

Clear

#
Clear the MultiDictionary.
public void Clear()

ContainsKey

#
Test whether a specific key is defined.
public bool ContainsKey(
TKey
key
Key to test.
)
True if key has been defined.

KeyValence

#
Gets the number of values associated with the given key.
public int KeyValence(
TKey
key
Key to test.
)
Number of items associated with key.

Remove

#
Remove a specific value associated with a specific key.
public bool Remove(
TKey
key,
Key associated with value.
TValue
value
Value to remove.
)

Remove

#
Remove all values associated with the specified key.
public bool Remove(
TKey
key
Key to remove.
)

RemoveAll

#
Remove all occurences of a specific value.
public int RemoveAll(
TValue
value
Value to remove.
)
Number of instances removed.

RemoveListsByLength

#
Remove all entries that contain lists shorter than or longer than the specified limits.
public int RemoveListsByLength(
minimum,
Minimum allowed list length. Any entry with fewer than minimum items will be removed.
maximum
Maximum allowed list length. Any entry with more than maximum items will be removed.
)
Number of keys removed.

TryGetAll

#
Try to get all values associated with a specific key.
public TValue[] TryGetAll(
TKey
key
Key.
)
Array of values associated with key.

TryGetFirst

#
Try to get the get the first value associated with a specific key.
public bool TryGetFirst(
TKey
key,
Key.
out TValue
value
First value associated with key.
)
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.
public bool TryGetOne(
TKey
key,
Key to search for.
out TValue
value
Single value will be returned here.
)
True on success, false on failure.

ValencePairs

#
Gets all key/value pairs that are within some valence range.
public IEnumerable<KeyValuePair<TKey, TValue>> ValencePairs(
minimum,
Inclusive lowest valence to include.
maximum
Inclusive highest valence to include.
)
Enumerable collection of pairs.