CollectionExtensions Class |
Namespace: TomsToolbox.Essentials
The CollectionExtensions type exposes the following members.
Name | Description | |
---|---|---|
AddRange(IList, IEnumerable) |
Adds the elements of the specified collection to the end of the list.
| |
AddRangeT(ICollectionT, IEnumerableT) |
Adds the elements of the specified collection to the end of the list.
| |
AddRangeT(ICollectionT, T, T, T) |
Adds the elements of the specified collection to the end of the list.
| |
ContainsAny(String, Char) |
Shortcut to test if any of the given characters is contained in the specified string.
| |
ContainsAnyT(IEnumerableT, T) |
Shortcut to test if any of the given items are contained in the specified object.
| |
ContainsAnyT(IEnumerableT, IEqualityComparerT, T) |
Shortcut to test if any of the given items are contained in the specified object.
| |
FindIndexT |
Searches for an element that matches the conditions defined by the specified predicate,
and returns the zero-based index of the first occurrence within the entire IEnumerableT.
| |
ForceValueTKey, TValue(IDictionaryTKey, TValue, TKey, TValue) |
Gets the value associated with the specified key from the dictionary, or creates a new entry if the dictionary does not contain a value associated with the key.
| |
ForceValueTKey, TValue(IDictionaryTKey, TValue, TKey, FuncTKey, TValue) |
Gets the value associated with the specified key from the dictionary, or creates a new entry if the dictionary does not contain a value associated with the key.
| |
ForEachT(IEnumerableT, ActionT, Int32) |
Performs the specified action on each element of the collection, providing also the index of the item.
| |
ForEachT(IEnumerableT, ActionT) |
Performs the specified action on each element of the collection.
| |
GetValueOrDefaultTKey, TValue(DictionaryTKey, TValue, TKey) |
Gets the value from the dictionary, or the default value of TValue if no item with the specified key exists.
| |
GetValueOrDefaultTKey, TValue(IDictionaryTKey, TValue, TKey) |
Gets the value from the dictionary, or the default value of TValue if no item with the specified key exists.
| |
GetValueOrDefaultTKey, TValue(IReadOnlyDictionaryTKey, TValue, TKey) |
Gets the value from the dictionary, or the default value of TValue if no item with the specified key exists.
| |
GetValueOrDefaultTKey, TValue(DictionaryTKey, TValue, TKey, TValue) |
Gets the value from the dictionary, or the default value if no item with the specified key exists.
| |
GetValueOrDefaultTKey, TValue(IDictionaryTKey, TValue, TKey, TValue) |
Gets the value from the dictionary, or the default value if no item with the specified key exists.
| |
GetValueOrDefaultTKey, TValue(IReadOnlyDictionaryTKey, TValue, TKey, TValue) |
Gets the value from the dictionary, or the default value if no item with the specified key exists.
| |
IndexOfT(IEnumerableT, T) |
Searches for the specified object and returns the zero-based index of the first occurrence within all items.
| |
IndexOfT(IEnumerableT, T, IEqualityComparerT) |
Searches for the specified object and returns the zero-based index of the first occurrence within all items.
| |
RemoveRange(IList, IEnumerable) |
Removes a range of elements from the list.
| |
RemoveRangeT(ICollectionT, IEnumerableT) |
Removes a range of elements from the list.
| |
RemoveWhereT |
Removes the range of elements from the list that fulfill the condition.
| |
RepeatT |
Repeats the specified source multiple times.
| |
SynchronizeWithT(ICollectionT, ICollectionT) |
Synchronizes the items of the source list with the items of the target list. The order of the items is ignored.
| |
SynchronizeWithT(ICollectionT, ICollectionT, IEqualityComparerT) |
Synchronizes the items of the source list with the items of the target list. The order of the items is ignored.
| |
TakeT |
Retrieves the specified number of items from the source. If source contains less items than specified, all available items are returned.
| |
ToArrayTSource, TTarget |
Creates an array from a ICollectionT.
This method is faster than using Enumerable.Select(selector).ToArray() because the size of the target array is known in advance.
| |
ToDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue) |
Creates a Dictionary{TKey, TValue} from an IEnumerable{KeyValuePair{TKey, TValue}}.
| |
ToDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue, IEqualityComparerTKey) |
Creates a Dictionary{TKey, TValue} from an IEnumerable{KeyValuePair{TKey, TValue}}.
| |
TransposeTKey, TValue |
Transposes the specified items, i.e. exchanges key and value.
| |
TryAddRangeT |
Adds the elements of the specified collection to the end of the list, but ignores all ArgumentException, e.g. when trying to add duplicate keys to a dictionary.
|