Method PartialSort
PartialSort<T>(IAsyncEnumerable<T>, int)
Executes a partial sort of the top count elements of a sequence. If count
is less than the total number of elements in source, then this method will improve
performance.
Declaration
public static IAsyncEnumerable<T> PartialSort<T>(this IAsyncEnumerable<T> source, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<T> | source | The source sequence. |
| int | count | Number of (maximum) elements to return. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | A sequence containing at most top |
Type Parameters
| Name | Description |
|---|---|
| T | Type of elements in the sequence. |
Remarks
This operation is an O(n * log(K)) where K is count.
This operator uses deferred execution and streams it results.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
PartialSort<T>(IAsyncEnumerable<T>, int, OrderByDirection)
Executes a direction partial sort of the top count elements of a sequence.
If count is less than the total number of elements in source, then this
method will improve performance.
Declaration
public static IAsyncEnumerable<T> PartialSort<T>(this IAsyncEnumerable<T> source, int count, OrderByDirection direction)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<T> | source | The source sequence. |
| int | count | Number of (maximum) elements to return. |
| OrderByDirection | direction | The direction in which to sort the elements |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | A sequence containing at most top |
Type Parameters
| Name | Description |
|---|---|
| T | Type of elements in the sequence. |
Remarks
This operation is an O(n * log(K)) where K is count.
This operator uses deferred execution and streams it results.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
PartialSort<T>(IAsyncEnumerable<T>, int, IComparer<T>?)
Executes a partial sort of the top count elements of a sequence, using comparer to compare elements. If count is less than the total number of elements in
source, then this method will improve performance.
Declaration
public static IAsyncEnumerable<T> PartialSort<T>(this IAsyncEnumerable<T> source, int count, IComparer<T>? comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<T> | source | The source sequence. |
| int | count | Number of (maximum) elements to return. |
| IComparer<T> | comparer | A IComparer<T> to compare elements. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | A sequence containing at most top |
Type Parameters
| Name | Description |
|---|---|
| T | Type of elements in the sequence. |
Remarks
This operation is an O(n * log(K)) where K is count.
This operator uses deferred execution and streams it results.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
PartialSort<T>(IAsyncEnumerable<T>, int, IComparer<T>?, OrderByDirection)
Executes a direction partial sort of the top count elements of a sequence,
using comparer to compare elements. If count is less than the total number
of elements in source, then this method will improve performance.
Declaration
public static IAsyncEnumerable<T> PartialSort<T>(this IAsyncEnumerable<T> source, int count, IComparer<T>? comparer, OrderByDirection direction)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<T> | source | The source sequence. |
| int | count | Number of (maximum) elements to return. |
| IComparer<T> | comparer | A IComparer<T> to compare elements. |
| OrderByDirection | direction | The direction in which to sort the elements |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<T> | A sequence containing at most top |
Type Parameters
| Name | Description |
|---|---|
| T | Type of elements in the sequence. |
Remarks
This operation is an O(n * log(K)) where K is count.
This operator uses deferred execution and streams it results.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|