Method Segment
View SourceSegment<T>(IAsyncEnumerable<T>, Func<T, bool>)
Divides a sequence into multiple sequences by using a segment detector based on the original sequence
Declaration
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, bool> newSegmentPredicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The sequence to segment |
Func<T, bool> | newSegmentPredicate | A function, which returns true if the given element begins a new segment, and false otherwise |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyList<T>> | A sequence of segment, each of which is a portion of the original sequence |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either |
Segment<T>(IAsyncEnumerable<T>, Func<T, ValueTask<bool>>)
Divides a sequence into multiple sequences by using a segment detector based on the original sequence
Declaration
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, ValueTask<bool>> newSegmentPredicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The sequence to segment |
Func<T, ValueTask<bool>> | newSegmentPredicate | A function, which returns true if the given element begins a new segment, and false otherwise |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyList<T>> | A sequence of segment, each of which is a portion of the original sequence |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either |
Segment<T>(IAsyncEnumerable<T>, Func<T, int, bool>)
Divides a sequence into multiple sequences by using a segment detector based on the original sequence
Declaration
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, int, bool> newSegmentPredicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The sequence to segment |
Func<T, int, bool> | newSegmentPredicate | A function, which returns true if the given element or index indicate a new segment, and false otherwise |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyList<T>> | A sequence of segment, each of which is a portion of the original sequence |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either |
Segment<T>(IAsyncEnumerable<T>, Func<T, int, ValueTask<bool>>)
Divides a sequence into multiple sequences by using a segment detector based on the original sequence
Declaration
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, int, ValueTask<bool>> newSegmentPredicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The sequence to segment |
Func<T, int, ValueTask<bool>> | newSegmentPredicate | A function, which returns true if the given element or index indicate a new segment, and false otherwise |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyList<T>> | A sequence of segment, each of which is a portion of the original sequence |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either |
Segment<T>(IAsyncEnumerable<T>, Func<T, T, int, bool>)
Divides a sequence into multiple sequences by using a segment detector based on the original sequence
Declaration
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, T, int, bool> newSegmentPredicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The sequence to segment |
Func<T, T, int, bool> | newSegmentPredicate | A function, which returns true if the given current element, previous element or index indicate a new segment, and false otherwise |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyList<T>> | A sequence of segment, each of which is a portion of the original sequence |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either |
Segment<T>(IAsyncEnumerable<T>, Func<T, T, int, ValueTask<bool>>)
Divides a sequence into multiple sequences by using a segment detector based on the original sequence
Declaration
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, T, int, ValueTask<bool>> newSegmentPredicate)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The sequence to segment |
Func<T, T, int, ValueTask<bool>> | newSegmentPredicate | A function, which returns true if the given current element, previous element or index indicate a new segment, and false otherwise |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IReadOnlyList<T>> | A sequence of segment, each of which is a portion of the original sequence |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either |