Interface IMultiDictionary<TKey, TValue>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic collection of (key, value-range) pairs.
public interface IMultiDictionary<TKey, TValue> : IDictionary<TKey, IReadOnlyList<TValue>>, ICollection<KeyValuePair<TKey, IReadOnlyList<TValue>>>, IReadOnlyMultiDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, IReadOnlyList<TValue>>, IReadOnlyCollection<KeyValuePair<TKey, IReadOnlyList<TValue>>>, IEnumerable<KeyValuePair<TKey, IReadOnlyList<TValue>>>, ILookup<TKey, TValue>, IEnumerable<IGrouping<TKey, TValue>>, IEnumerable where TKey : notnull
Type Parameters
TKeyKey type.
TValueValue type.
- Inherited Members
- Extension Methods
Properties
Count
Gets the number of elements contained in the ICollection<T>.
int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
this[TKey]
Gets or sets the element with the specified key.
IReadOnlyList<TValue> this[TKey key] { get; set; }
Parameters
keyTKeyThe key of the element to get or set.
Property Value
- IReadOnlyList<TValue>
The element with the specified key.
Exceptions
- ArgumentNullException
keyis null.- KeyNotFoundException
The property is retrieved and
keyis not found.- NotSupportedException
The property is set and the IDictionary<TKey, TValue> is read-only.
Keys
Gets an ICollection<T> containing the keys of the IDictionary<TKey, TValue>.
IReadOnlyCollection<TKey> Keys { get; }
Property Value
- IReadOnlyCollection<TKey>
An ICollection<T> containing the keys of the object that implements IDictionary<TKey, TValue>.
Values
Gets an ICollection<T> containing the values in the IDictionary<TKey, TValue>.
IReadOnlyCollection<IReadOnlyList<TValue>> Values { get; }
Property Value
- IReadOnlyCollection<IReadOnlyList<TValue>>
An ICollection<T> containing the values in the object that implements IDictionary<TKey, TValue>.
Methods
Add(TKey, TValue)
Adds a new entry to this dictionary.
void Add(TKey key, TValue value)
Parameters
keyTKeyEntry's key.
valueTValueEntry's value.
AddRange(TKey, IEnumerable<TValue>)
Adds a range of entries associated with the provided key to this dictionary.
void AddRange(TKey key, IEnumerable<TValue> values)
Parameters
keyTKeyEntry's key.
valuesIEnumerable<TValue>Range of values.
ContainsKey(TKey)
Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.
[Pure]
bool ContainsKey(TKey key)
Parameters
keyTKeyThe key to locate in the IDictionary<TKey, TValue>.
Returns
- bool
true if the IDictionary<TKey, TValue> contains an element with the key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.
Remove(TKey)
Removes all elements associated with the specified key.
IReadOnlyList<TValue> Remove(TKey key)
Parameters
keyTKeyKey to remove.
Returns
- IReadOnlyList<TValue>
All removed elements associated with the specified
key.
Remove(TKey, TValue)
Attempts to remove a specific element associated with the specified key.
bool Remove(TKey key, TValue value)
Parameters
keyTKeyEntry's key.
valueTValueValue to remove.
Returns
- bool
true when key exists and value has been removed, otherwise false.
RemoveAll(TKey, Predicate<TValue>)
Attempts to remove all elements associated with the specified key
that pass the provided predicate.
int RemoveAll(TKey key, Predicate<TValue> predicate)
Parameters
keyTKeyEntry's key.
predicatePredicate<TValue>Delegate that defines which elements to remove.
Returns
- int
Number of removed elements.
RemoveAt(TKey, int)
Attempts to remove an element associated with the specified key at the provided index.
bool RemoveAt(TKey key, int index)
Parameters
keyTKeyEntry's key.
indexint0-based position of an element to remove.
Returns
- bool
true when an element has been removed, otherwise false.
Exceptions
- ArgumentOutOfRangeException
When
indexis less than 0 or greater than or equal to the number of elements associated with the specifiedkey.
RemoveRange(TKey, int, int)
Attempts to remove a range of elements associated with the specified key.
bool RemoveRange(TKey key, int index, int count)
Parameters
keyTKeyEntry's key.
indexint0-based position of a first element to remove.
countintTotal number of elements to remove, starting from the provided
key.
Returns
- bool
true when a range of elements has been removed, otherwise false.
Exceptions
- ArgumentOutOfRangeException
When
indexorcountis less than 0.- ArgumentException
When
indexandcountdo not denote a valid range of elements.
SetRange(TKey, IEnumerable<TValue>)
Sets a range of entries associated with the provided key in this dictionary.
void SetRange(TKey key, IEnumerable<TValue> values)
Parameters
keyTKeyEntry's key.
valuesIEnumerable<TValue>Range of values.
TryGetValue(TKey, out IReadOnlyList<TValue>)
Gets the value associated with the specified key.
bool TryGetValue(TKey key, out IReadOnlyList<TValue> result)
Parameters
keyTKeyThe key whose value to get.
resultIReadOnlyList<TValue>
Returns
- bool
true if the object that implements IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.