Method DensePartialSortBy
View SourceDensePartialSortBy<TSource, TKey>(IAsyncEnumerable<TSource>, int, Func<TSource, TKey>)
Executes a partial sort of the top count
elements of a sequence, including ties, according to
the key for each element. If count
is less than the total number of elements in source
, then this method will improve performance.
Declaration
public static IAsyncEnumerable<TSource> DensePartialSortBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, int count, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
int | count | Number of (maximum) elements to return. |
Func<TSource, TKey> | keySelector | A function to extract a key from an element. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A sequence containing at most top |
Type Parameters
Name | Description |
---|---|
TSource | Type of elements in the sequence. |
TKey | Type of keys. |
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 |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
DensePartialSortBy<TSource, TKey>(IAsyncEnumerable<TSource>, int, Func<TSource, TKey>, OrderByDirection)
Executes a direction
partial sort of the top count
elements of a sequence,
including ties, according to the key for each element. If count
is less than the total number
of elements in source
, then this method will improve performance.
Declaration
public static IAsyncEnumerable<TSource> DensePartialSortBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, int count, Func<TSource, TKey> keySelector, OrderByDirection direction)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
int | count | Number of (maximum) elements to return. |
Func<TSource, TKey> | keySelector | A function to extract a key from an element. |
OrderByDirection | direction | The direction in which to sort the elements |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A sequence containing at most top |
Type Parameters
Name | Description |
---|---|
TSource | Type of elements in the sequence. |
TKey | Type of keys. |
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 |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
DensePartialSortBy<TSource, TKey>(IAsyncEnumerable<TSource>, int, Func<TSource, TKey>, IComparer<TKey>?)
Executes a partial sort of the top count
elements of a sequence, including ties, according to
the key for each element, using comparer
to compare the keys. If count
is
less than the total number of elements in source
, then this method will improve performance.
Declaration
public static IAsyncEnumerable<TSource> DensePartialSortBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, int count, Func<TSource, TKey> keySelector, IComparer<TKey>? comparer)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
int | count | Number of (maximum) elements to return. |
Func<TSource, TKey> | keySelector | A function to extract a key from an element. |
IComparer<TKey> | comparer | A IComparer<T> to compare elements. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A sequence containing at most top |
Type Parameters
Name | Description |
---|---|
TSource | Type of elements in the sequence. |
TKey | Type of keys. |
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 |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
DensePartialSortBy<TSource, TKey>(IAsyncEnumerable<TSource>, int, Func<TSource, TKey>, IComparer<TKey>?, OrderByDirection)
Executes a direction
partial sort of the top count
elements of a sequence,
including ties, according to the key for each element, using comparer
to compare the keys. If
count
is less than the total number of elements in source
, then this
method will improve performance.
Declaration
public static IAsyncEnumerable<TSource> DensePartialSortBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, int count, Func<TSource, TKey> keySelector, IComparer<TKey>? comparer, OrderByDirection direction)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The source sequence. |
int | count | Number of (maximum) elements to return. |
Func<TSource, TKey> | keySelector | A function to extract a key from an element. |
IComparer<TKey> | comparer | A IComparer<T> to compare elements. |
OrderByDirection | direction | The direction in which to sort the elements |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A sequence containing at most top |
Type Parameters
Name | Description |
---|---|
TSource | Type of elements in the sequence. |
TKey | Type of keys. |
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 |
|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|