Class DictionaryExtensions
Extensions for all items of type IDictionary<TKey, TValue>.
Inherited Members
Namespace: TheXDS.MCART.Types.Extensions
Assembly: MCART.dll
Syntax
public static class DictionaryExtensions
Methods
| Edit this page View SourceCheckCircularRef<T>(IDictionary<T, ICollection<T>>, T)
Checks for circular references in a dictionary of objects.
Declaration
public static bool CheckCircularRef<T>(this IDictionary<T, ICollection<T>> dictionary, T element) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
IDictionary<T, ICollection<T>> | dictionary | Dictionary in which to perform the check. |
T | element | Element to check. |
Returns
Type | Description |
---|---|
bool | false if no circular references exist within the dictionary, true otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements contained in the dictionary. |
CheckCircularRef<T>(IDictionary<T, IEnumerable<T>>, T)
Checks for circular references in a dictionary of tree-shaped objects.
Declaration
public static bool CheckCircularRef<T>(this IDictionary<T, IEnumerable<T>> dictionary, T element) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
IDictionary<T, IEnumerable<T>> | dictionary | Dictionary in which to perform the check. |
T | element | Element to check. |
Returns
Type | Description |
---|---|
bool | false if no circular references exist within the dictionary, true otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements contained in the dictionary. |
CheckCircularRef<T>(IEnumerable<KeyValuePair<T, ICollection<T>>>, T)
Checks for circular references in a dictionary of objects.
Declaration
public static bool CheckCircularRef<T>(this IEnumerable<KeyValuePair<T, ICollection<T>>> dictionary, T element) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<T, ICollection<T>>> | dictionary | Dictionary in which to perform the check. |
T | element | Element to check. |
Returns
Type | Description |
---|---|
bool | false if no circular references exist within the dictionary, true otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements contained in the dictionary. |
CheckCircularRef<T>(IEnumerable<KeyValuePair<T, IEnumerable<T>>>, T)
Checks for circular references in a dictionary of objects.
Declaration
public static bool CheckCircularRef<T>(this IEnumerable<KeyValuePair<T, IEnumerable<T>>> dictionary, T element) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<T, IEnumerable<T>>> | dictionary | Dictionary in which to perform the check. |
T | element | Element to check. |
Returns
Type | Description |
---|---|
bool | false if no circular references exist within the dictionary, true otherwise. |
Type Parameters
Name | Description |
---|---|
T | Type of elements contained in the dictionary. |
Pop<TKey, TValue>(IDictionary<TKey, TValue>, TKey, out TValue)
Gets the element with the specified key from the dictionary, removing it.
Declaration
public static bool Pop<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, out TValue value) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dictionary | Dictionary from which to get and remove the object. |
TKey | key | Key of the object to get. |
TValue | value | Value obtained from the dictionary. |
Returns
Type | Description |
---|---|
bool | true if the object was successfully removed from the dictionary, false if the dictionary did not contain an element with the specified key. |
Type Parameters
Name | Description |
---|---|
TKey | Key type of the object to get. |
TValue | Value type contained by the dictionary. |
PushInto<TKey, TValue>(TValue, TKey, IDictionary<TKey, TValue>)
Adds a value to the specified dictionary.
Declaration
public static TValue PushInto<TKey, TValue>(this TValue value, TKey key, IDictionary<TKey, TValue> dictionary) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
TValue | value | Value to add. |
TKey | key | Key to identify the new value. |
IDictionary<TKey, TValue> | dictionary | Dictionary to which to add the new value. |
Returns
Type | Description |
---|---|
TValue | The same instance as |
Type Parameters
Name | Description |
---|---|
TKey | Key type to use to identify the value. |
TValue | Type of value to add. |
Push<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Adds a value to the dictionary.
Declaration
public static TValue Push<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dictionary | Dictionary to which to add the new value. |
TKey | key | Key to identify the new value. |
TValue | value | Value to add. |
Returns
Type | Description |
---|---|
TValue | The same instance as |
Type Parameters
Name | Description |
---|---|
TKey | Key type to use to identify the value. |
TValue | Type of value to add. |