1
0

IIListProvider.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections.Generic;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace System.Linq
  5. {
  6. /// <summary>
  7. /// An iterator that can produce an array or <see cref="List{TElement}"/> through an optimized path.
  8. /// </summary>
  9. internal interface IIListProvider<TElement> : IAsyncEnumerable<TElement>
  10. {
  11. /// <summary>
  12. /// Produce an array of the sequence through an optimized path.
  13. /// </summary>
  14. /// <param name="cancellationToken"></param>
  15. /// <returns>The array.</returns>
  16. Task<TElement[]> ToArrayAsync(CancellationToken cancellationToken);
  17. /// <summary>
  18. /// Produce a <see cref="List{TElement}"/> of the sequence through an optimized path.
  19. /// </summary>
  20. /// <param name="cancellationToken"></param>
  21. /// <returns>The <see cref="List{TElement}"/>.</returns>
  22. Task<List<TElement>> ToListAsync(CancellationToken cancellationToken);
  23. /// <summary>
  24. /// Returns the count of elements in the sequence.
  25. /// </summary>
  26. /// <param name="onlyIfCheap">If true then the count should only be calculated if doing
  27. /// so is quick (sure or likely to be constant time), otherwise -1 should be returned.</param>
  28. /// <param name="cancellationToken"></param>
  29. /// <returns>The number of elements.</returns>
  30. Task<int> GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken);
  31. }
  32. }