IOrderedAsyncEnumerable.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Linq
  8. {
  9. #if INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
  10. /// <summary>
  11. /// Represents a sorted async-enumerable sequence.
  12. /// </summary>
  13. /// <typeparam name="TElement">The type of the elements of the sequence.</typeparam>
  14. public interface IOrderedAsyncEnumerable<out TElement> : IAsyncEnumerable<TElement>
  15. {
  16. /// <summary>
  17. /// Performs a subsequent ordering on the elements of an ordered async-enumerable according to a key.
  18. /// </summary>
  19. /// <typeparam name="TKey">The type of the key produced by keySelector.</typeparam>
  20. /// <param name="keySelector">The function used to extract the key for each element.</param>
  21. /// <param name="comparer">The comparer used to compare keys for placement in the returned sequence.</param>
  22. /// <param name="descending">true to sort the elements in descending order; false to sort the elements in ascending order.</param>
  23. /// <returns>An ordered async-enumerable whose elements are sorted according to a key.</returns>
  24. IOrderedAsyncEnumerable<TElement> CreateOrderedEnumerable<TKey>(Func<TElement, TKey> keySelector, IComparer<TKey>? comparer, bool descending);
  25. /// <summary>
  26. /// Performs a subsequent ordering on the elements of an ordered async-enumerable according to a key provided via a ValueTask.
  27. /// </summary>
  28. /// <typeparam name="TKey">The type of the key produced by keySelector.</typeparam>
  29. /// <param name="keySelector">The function used to extract the key for each element as a ValueTask.</param>
  30. /// <param name="comparer">The comparer used to compare keys for placement in the returned sequence.</param>
  31. /// <param name="descending">true to sort the elements in descending order; false to sort the elements in ascending order.</param>
  32. /// <returns>An ordered async-enumerable whose elements are sorted according to a key.</returns>
  33. IOrderedAsyncEnumerable<TElement> CreateOrderedEnumerable<TKey>(Func<TElement, ValueTask<TKey>> keySelector, IComparer<TKey>? comparer, bool descending);
  34. #if !NO_DEEP_CANCELLATION
  35. /// <summary>
  36. /// Performs a subsequent ordering on the elements of an ordered async-enumerable according to a key provided via a ValueTask.
  37. /// </summary>
  38. /// <typeparam name="TKey">The type of the key produced by keySelector.</typeparam>
  39. /// <param name="keySelector">The function used to extract the key for each element as a ValueTask supporting cancellation.</param>
  40. /// <param name="comparer">The comparer used to compare keys for placement in the returned sequence.</param>
  41. /// <param name="descending">true to sort the elements in descending order; false to sort the elements in ascending order.</param>
  42. /// <returns>An ordered async-enumerable whose elements are sorted according to a key.</returns>
  43. IOrderedAsyncEnumerable<TElement> CreateOrderedEnumerable<TKey>(Func<TElement, CancellationToken, ValueTask<TKey>> keySelector, IComparer<TKey>? comparer, bool descending);
  44. #endif
  45. }
  46. #endif // INCLUDE_SYSTEM_LINQ_ASYNCENUMERABLE_DUPLICATES
  47. }