-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ee90f0
commit b8564b5
Showing
7 changed files
with
421 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
namespace SuperLinq.Async; | ||
|
||
public static partial class AsyncSuperEnumerable | ||
{ | ||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="T">Type of elements in the sequence.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSort{T}(IAsyncEnumerable{T}, int, OrderByDirection)"/> with a | ||
/// <c>direction</c> of <see cref="OrderByDirection.Descending"/> and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<T> MaxItems<T>(this IAsyncEnumerable<T> source) | ||
{ | ||
return source.DensePartialSort(1, OrderByDirection.Descending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="T">Type of elements in the sequence.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="comparer">A <see cref="IComparer{T}"/> to compare elements.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSort{T}(IAsyncEnumerable{T}, int, IComparer{T}?, OrderByDirection)"/> with a | ||
/// <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<T> MaxItems<T>(this IAsyncEnumerable<T> source, IComparer<T>? comparer) | ||
{ | ||
return source.DensePartialSort(1, comparer, OrderByDirection.Descending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="TSource">Type of elements in the sequence.</typeparam> | ||
/// <typeparam name="TKey">Type of keys.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="keySelector">A function to extract a key from an element.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSortBy{TSource, TKey}(IAsyncEnumerable{TSource}, int, | ||
/// Func{TSource, TKey}, OrderByDirection)"/> with a <c>direction</c> of <see cref="OrderByDirection.Descending"/> | ||
/// and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<TSource> MaxItemsBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector) | ||
{ | ||
return source.DensePartialSortBy(1, keySelector, OrderByDirection.Descending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="TSource">Type of elements in the sequence.</typeparam> | ||
/// <typeparam name="TKey">Type of keys.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="keySelector">A function to extract a key from an element.</param> | ||
/// <param name="comparer">A <see cref="IComparer{T}"/> to compare keys.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSortBy{TSource, TKey}(IAsyncEnumerable{TSource}, int, | ||
/// Func{TSource, TKey}, IComparer{TKey}?, OrderByDirection)"/> with a <c>direction</c> of <see | ||
/// cref="OrderByDirection.Descending"/> and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<TSource> MaxItemsBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey>? comparer) | ||
{ | ||
return source.DensePartialSortBy(1, keySelector, comparer, OrderByDirection.Descending); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
namespace SuperLinq.Async; | ||
|
||
public static partial class AsyncSuperEnumerable | ||
{ | ||
/// <summary> | ||
/// Returns all of the items that share the minimum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="T">Type of elements in the sequence.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSort{T}(IAsyncEnumerable{T}, int, OrderByDirection)"/> with a | ||
/// <c>direction</c> of <see cref="OrderByDirection.Ascending"/> and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<T> MinItems<T>(this IAsyncEnumerable<T> source) | ||
{ | ||
return source.DensePartialSort(1, OrderByDirection.Ascending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the minimum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="T">Type of elements in the sequence.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="comparer">A <see cref="IComparer{T}"/> to compare elements.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSort{T}(IAsyncEnumerable{T}, int, IComparer{T}?, OrderByDirection)"/> with a | ||
/// <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<T> MinItems<T>(this IAsyncEnumerable<T> source, IComparer<T>? comparer) | ||
{ | ||
return source.DensePartialSort(1, comparer, OrderByDirection.Ascending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the minimum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="TSource">Type of elements in the sequence.</typeparam> | ||
/// <typeparam name="TKey">Type of keys.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="keySelector">A function to extract a key from an element.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSortBy{TSource, TKey}(IAsyncEnumerable{TSource}, int, | ||
/// Func{TSource, TKey}, OrderByDirection)"/> with a <c>direction</c> of <see cref="OrderByDirection.Ascending"/> | ||
/// and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<TSource> MinItemsBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector) | ||
{ | ||
return source.DensePartialSortBy(1, keySelector, OrderByDirection.Ascending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the minimum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="TSource">Type of elements in the sequence.</typeparam> | ||
/// <typeparam name="TKey">Type of keys.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="keySelector">A function to extract a key from an element.</param> | ||
/// <param name="comparer">A <see cref="IComparer{T}"/> to compare keys.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSortBy{TSource, TKey}(IAsyncEnumerable{TSource}, int, | ||
/// Func{TSource, TKey}, IComparer{TKey}?, OrderByDirection)"/> with a <c>direction</c> of <see | ||
/// cref="OrderByDirection.Ascending"/> and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IAsyncEnumerable<TSource> MinItemsBy<TSource, TKey>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey>? comparer) | ||
{ | ||
return source.DensePartialSortBy(1, keySelector, comparer, OrderByDirection.Ascending); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
namespace SuperLinq; | ||
|
||
public static partial class SuperEnumerable | ||
{ | ||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="T">Type of elements in the sequence.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSort{T}(IEnumerable{T}, int, OrderByDirection)"/> with a | ||
/// <c>direction</c> of <see cref="OrderByDirection.Descending"/> and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IEnumerable<T> MaxItems<T>(this IEnumerable<T> source) | ||
{ | ||
return source.DensePartialSort(1, OrderByDirection.Descending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="T">Type of elements in the sequence.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="comparer">A <see cref="IComparer{T}"/> to compare elements.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSort{T}(IEnumerable{T}, int, IComparer{T}?, OrderByDirection)"/> with a | ||
/// <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IEnumerable<T> MaxItems<T>(this IEnumerable<T> source, IComparer<T>? comparer) | ||
{ | ||
return source.DensePartialSort(1, comparer, OrderByDirection.Descending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="TSource">Type of elements in the sequence.</typeparam> | ||
/// <typeparam name="TKey">Type of keys.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="keySelector">A function to extract a key from an element.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSortBy{TSource, TKey}(IEnumerable{TSource}, int, | ||
/// Func{TSource, TKey}, OrderByDirection)"/> with a <c>direction</c> of <see cref="OrderByDirection.Descending"/> | ||
/// and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IEnumerable<TSource> MaxItemsBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) | ||
{ | ||
return source.DensePartialSortBy(1, keySelector, OrderByDirection.Descending); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the items that share the maximum value of a sequence. | ||
/// </summary> | ||
/// <typeparam name="TSource">Type of elements in the sequence.</typeparam> | ||
/// <typeparam name="TKey">Type of keys.</typeparam> | ||
/// <param name="source">The source sequence.</param> | ||
/// <param name="keySelector">A function to extract a key from an element.</param> | ||
/// <param name="comparer">A <see cref="IComparer{T}"/> to compare keys.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception> | ||
/// <remarks> | ||
/// <para> | ||
/// This operator is a shortcut for <see cref="DensePartialSortBy{TSource, TKey}(IEnumerable{TSource}, int, | ||
/// Func{TSource, TKey}, IComparer{TKey}?, OrderByDirection)"/> with a <c>direction</c> of <see | ||
/// cref="OrderByDirection.Descending"/> and a <c>count</c> of <c>1</c>. | ||
/// </para> | ||
/// <para> | ||
/// This operator uses deferred execution and streams it results. | ||
/// </para> | ||
/// </remarks> | ||
public static IEnumerable<TSource> MaxItemsBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey>? comparer) | ||
{ | ||
return source.DensePartialSortBy(1, keySelector, comparer, OrderByDirection.Descending); | ||
} | ||
} |
Oops, something went wrong.