Class ListDictionary<TKey, TValue>
A dictionary of lists.
Inheritance
Implements
Namespace: Sartorius.SAF.Infrastructure
Assembly: Sartorius.SAF.dll
Syntax
public sealed class ListDictionary<TKey, TValue> : IDictionary<TKey, IList<TValue>>, ICollection<KeyValuePair<TKey, IList<TValue>>>, IEnumerable<KeyValuePair<TKey, IList<TValue>>>, IEnumerable
Type Parameters
Name | Description |
---|---|
TKey | The key to use for lists. |
TValue | The type of the value held by lists. |
Properties
View SourceCount
Gets the number of lists in the dictionary.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Value indicating the values count. |
Item[TKey]
Gets or sets the list associated with the given key. The access always succeeds, eventually returning an empty list.
Declaration
public IList<TValue> this[TKey key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the list to access. |
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<TValue> | The list associated with the key. |
Keys
Gets the list of keys in the dictionary.
Declaration
public ICollection<TKey> Keys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<TKey> | Collection of keys. |
Values
Gets a shallow copy of all values in all lists.
Declaration
public IList<TValue> Values { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<TValue> | List of values. |
Methods
View SourceAdd(TKey)
If a list does not already exist, it will be created automatically.
Declaration
public void Add(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the list that will hold the value. |
Add(TKey, TValue)
Adds a value to a list with the given key. If a list does not already exist, it will be created automatically.
Declaration
public void Add(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the list that will hold the value. |
TValue | value | The value to add to the list under the given key. |
Clear()
Removes all entries in the dictionary.
Declaration
public void Clear()
ContainsKey(TKey)
Determines whether the dictionary contains the given key.
Declaration
public bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to locate. |
Returns
Type | Description |
---|---|
System.Boolean | true if the dictionary contains the given key; otherwise, false. |
ContainsValue(TValue)
Determines whether the dictionary contains the specified value.
Declaration
public bool ContainsValue(TValue value)
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value to locate. |
Returns
Type | Description |
---|---|
System.Boolean | true if the dictionary contains the value in any list; otherwise, false. |
FindAllValues(Predicate<TValue>)
Retrieves all the elements that match the condition defined by the specified predicate.
Declaration
public IEnumerable<TValue> FindAllValues(Predicate<TValue> valueFilter)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<TValue> | valueFilter | The filter with the condition to use to filter values. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TValue> | The elements that match the condition defined by the specified predicate. |
FindAllValuesByKey(Predicate<TKey>)
Retrieves the all the elements from the list which have a key that matches the condition defined by the specified predicate.
Declaration
public IEnumerable<TValue> FindAllValuesByKey(Predicate<TKey> keyFilter)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<TKey> | keyFilter | The filter with the condition to use to filter lists by their key. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TValue> | The elements that have a key that matches the condition defined by the specified predicate. |
Remove(TKey)
Removes a list by key.
Declaration
public bool Remove(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the list to remove. |
Returns
Type | Description |
---|---|
System.Boolean | true if the element was removed. |
Remove(TKey, TValue)
Removes a value from the list with the given key.
Declaration
public void Remove(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the list where the value exists. |
TValue | value | The value to remove. |
Remove(TValue)
Removes a value from all lists where it may be found.
Declaration
public void Remove(TValue value)
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value to remove. |
Explicit Interface Implementations
View SourceICollection<KeyValuePair<TKey, IList<TValue>>>.Add(KeyValuePair<TKey, IList<TValue>>)
See System.Collections.Generic.ICollection<T>.Add(T) for more information.
Declaration
void ICollection<KeyValuePair<TKey, IList<TValue>>>.Add(KeyValuePair<TKey, IList<TValue>> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.IList<TValue>> | item |
ICollection<KeyValuePair<TKey, IList<TValue>>>.Contains(KeyValuePair<TKey, IList<TValue>>)
See System.Collections.Generic.ICollection<T>.Contains(T) for more information.
Declaration
bool ICollection<KeyValuePair<TKey, IList<TValue>>>.Contains(KeyValuePair<TKey, IList<TValue>> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.IList<TValue>> | item |
Returns
Type | Description |
---|---|
System.Boolean |
ICollection<KeyValuePair<TKey, IList<TValue>>>.CopyTo(KeyValuePair<TKey, IList<TValue>>[], Int32)
See System.Collections.Generic.ICollection<T>.CopyTo(T[], System.Int32) for more information.
Declaration
void ICollection<KeyValuePair<TKey, IList<TValue>>>.CopyTo(KeyValuePair<TKey, IList<TValue>>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.IList<TValue>>[] | array | |
System.Int32 | arrayIndex |
ICollection<KeyValuePair<TKey, IList<TValue>>>.IsReadOnly
See System.Collections.Generic.ICollection<T>.IsReadOnly for more information.
Declaration
bool ICollection<KeyValuePair<TKey, IList<TValue>>>.IsReadOnly { get; }
Returns
Type | Description |
---|---|
System.Boolean |
ICollection<KeyValuePair<TKey, IList<TValue>>>.Remove(KeyValuePair<TKey, IList<TValue>>)
See System.Collections.Generic.ICollection<T>.Remove(T) for more information.
Declaration
bool ICollection<KeyValuePair<TKey, IList<TValue>>>.Remove(KeyValuePair<TKey, IList<TValue>> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.IList<TValue>> | item |
Returns
Type | Description |
---|---|
System.Boolean |
IDictionary<TKey, IList<TValue>>.Add(TKey, IList<TValue>)
Declaration
void IDictionary<TKey, IList<TValue>>.Add(TKey key, IList<TValue> value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
System.Collections.Generic.IList<TValue> | value |
IDictionary<TKey, IList<TValue>>.TryGetValue(TKey, out IList<TValue>)
See System.Collections.Generic.IDictionary<TKey, TValue>.TryGetValue(TKey, TValue) for more information.
Declaration
bool IDictionary<TKey, IList<TValue>>.TryGetValue(TKey key, out IList<TValue> value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | |
System.Collections.Generic.IList<TValue> | value |
Returns
Type | Description |
---|---|
System.Boolean |
IDictionary<TKey, IList<TValue>>.Values
See System.Collections.Generic.IDictionary<TKey, TValue>.Values for more information.
Declaration
ICollection<IList<TValue>> IDictionary<TKey, IList<TValue>>.Values { get; }
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Collections.Generic.IList<TValue>> |
IEnumerable<KeyValuePair<TKey, IList<TValue>>>.GetEnumerator()
See System.Collections.Generic.IEnumerable<T>.GetEnumerator() for more information.
Declaration
IEnumerator<KeyValuePair<TKey, IList<TValue>>> IEnumerable<KeyValuePair<TKey, IList<TValue>>>.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey, System.Collections.Generic.IList<TValue>>> |
IEnumerable.GetEnumerator()
See System.Collections.IEnumerable.GetEnumerator() for more information.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |