Method RunLengthEncode
View SourceRunLengthEncode<T>(IAsyncEnumerable<T>)
Run-length encodes a sequence by converting consecutive instances of the same element into a tuple representing the item and its occurrence count.
Declaration
public static IAsyncEnumerable<(T value, int count)> RunLengthEncode<T>(this IAsyncEnumerable<T> sequence)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | sequence | The sequence to run length encode |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(T value, int count)> | A sequence of tuples containing the element and the occurrence count |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
RunLengthEncode<T>(IAsyncEnumerable<T>, IEqualityComparer<T>?)
Run-length encodes a sequence by converting consecutive instances of the same element into a tuple representing the item and its occurrence count. This overload uses a custom equality comparer to identify equivalent items.
Declaration
public static IAsyncEnumerable<(T value, int count)> RunLengthEncode<T>(this IAsyncEnumerable<T> sequence, IEqualityComparer<T>? comparer)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | sequence | The sequence to run length encode |
IEqualityComparer<T> | comparer | The comparer used to identify equivalent items |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(T value, int count)> | A sequence of tuples containing the element and the occurrence count |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |