Skip to content

Latest commit

 

History

History
161 lines (144 loc) · 7.24 KB

File metadata and controls

161 lines (144 loc) · 7.24 KB

System.Collections.Generic


DictionaryExtensions

Provides extension methods for working with System.Collections.Generic.Dictionary2`. These methods enhance dictionary functionality with efficient retrieval, addition, and updating of values.

public static class DictionaryExtensions

Static Methods

GetOrAdd

TValue GetOrAdd(this Dictionary<TKey, TValue> dict, TKey key, TValue value)

Summary: Retrieves the value associated with the specified key or adds a new value if the key does not exist.

Parameters:
     dict  -  The dictionary instance.
     key  -  The key whose value to get or add.
     value  -  The value to add if the key does not exist.

Returns: The existing or newly added value.

GetOrAdd

TValue GetOrAdd(this Dictionary<TKey, TValue> dict, TKey key, Func<TKey, TValue> valueFactory)

Summary: Retrieves the value associated with the specified key or adds a new value if the key does not exist.

Parameters:
     dict  -  The dictionary instance.
     key  -  The key whose value to get or add.
     value  -  The value to add if the key does not exist.

Returns: The existing or newly added value.

TryUpdate

bool TryUpdate(this Dictionary<TKey, TValue> dict, TKey key, TValue value)

Summary: Attempts to update the value of an existing key in the dictionary.

Parameters:
     dict  -  The dictionary instance.
     key  -  The key whose value should be updated.
     value  -  The new value to assign.

Returns: true if the key exists and the value was updated; otherwise, false.

TryUpdate

bool TryUpdate(this Dictionary<TKey, TValue> dict, TKey key, Func<TKey, TValue, TValue> valueFactory)

Summary: Attempts to update the value of an existing key in the dictionary.

Parameters:
     dict  -  The dictionary instance.
     key  -  The key whose value should be updated.
     value  -  The new value to assign.

Returns: true if the key exists and the value was updated; otherwise, false.


EnumerableExtensions

Provides extension methods for asynchronous enumeration of collections.

public static class EnumerableExtensions

Static Methods

CountAsync

Task<int> CountAsync(this IEnumerable<T> source, CancellationToken cancellationToken = null)

Summary: Asynchronously counts the elements in a sequence.

Parameters:
     source  -  The source sequence to count.
     cancellationToken  -  A to observe while waiting for the asynchronous operation to complete.

Returns: A task that represents the asynchronous operation. The task result contains the number of elements in the sequence.

SelectToArray

TResult[] SelectToArray(this IEnumerable<TSource> source, Func<TSource, TResult> selector)

Summary: Projects each element of a sequence into a new form and returns the results as an array.

Parameters:
     source  -  The sequence of elements to transform.
     selector  -  A transform function to apply to each element.

Returns: An array containing the transformed elements from the source sequence.

Remarks: This is a convenience method that combines System.Linq.Enumerable.Select``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) and System.Linq.Enumerable.ToArray``1(System.Collections.Generic.IEnumerable{``0}).

SelectToList

List<TResult> SelectToList(this IEnumerable<TSource> source, Func<TSource, TResult> selector)

Summary: Projects each element of a sequence into a new form and returns the results as a System.Collections.Generic.List1`.

Parameters:
     source  -  The sequence of elements to transform.
     selector  -  A transform function to apply to each element.

Returns: A System.Collections.Generic.List1` containing the transformed elements from the source sequence.

Remarks: This is a convenience method that combines System.Linq.Enumerable.Select``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}) and System.Linq.Enumerable.ToList``1(System.Collections.Generic.IEnumerable{``0}).

ToAsyncEnumerable

IAsyncEnumerable<T> ToAsyncEnumerable(this IEnumerable<T> source, CancellationToken cancellationToken = null)

Summary: Converts an System.Collections.Generic.IEnumerable1to anSystem.Collections.Generic.IAsyncEnumerable1.

Parameters:
     source  -  The source sequence to convert.
     cancellationToken  -  A to observe while waiting for the asynchronous operation to complete.

Returns: An System.Collections.Generic.IAsyncEnumerable1` that contains the elements from the input sequence.

ToListAsync

Task<List<T>> ToListAsync(this IEnumerable<T> source, CancellationToken cancellationToken = null)

Summary: Asynchronously creates a System.Collections.Generic.List1from anSystem.Collections.Generic.IEnumerable1.

Parameters:
     source  -  The source sequence to convert to a list.
     cancellationToken  -  A to observe while waiting for the asynchronous operation to complete.

Returns: A task that represents the asynchronous operation. The task result contains a list with the elements from the input sequence.


ReadOnlyListExtensions

public static class ReadOnlyListExtensions

Static Methods

GetPowerSet

IEnumerable<IEnumerable<T>> GetPowerSet(this IReadOnlyList<T> list)

GetUniqueCombinations

IEnumerable<IEnumerable<string>> GetUniqueCombinations(this IReadOnlyList<string> list)

GetUniqueCombinationsAsCommaSeparated

IEnumerable<string> GetUniqueCombinationsAsCommaSeparated(this IReadOnlyList<string> list)

Generated by MarkdownCodeDoc version 1.2