Skip to content

Commit c7e6913

Browse files
Update operators to use IReadOnlyList<> (#599)
* Update `Split` to use `IReadOnlyList<>` as return type * Update `Segment` to use `IReadOnlyList<>` * Update `GroupAdjacent` to use `IReadOnlyList<>`
1 parent ac62852 commit c7e6913

File tree

16 files changed

+445
-149
lines changed

16 files changed

+445
-149
lines changed

Source/SuperLinq.Async/GroupAdjacent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static IAsyncEnumerable<IGrouping<TKey, TElement>> GroupAdjacent<TSource,
195195
public static IAsyncEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
196196
this IAsyncEnumerable<TSource> source,
197197
Func<TSource, TKey> keySelector,
198-
Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
198+
Func<TKey, IReadOnlyList<TSource>, TResult> resultSelector)
199199
{
200200
ArgumentNullException.ThrowIfNull(source);
201201
ArgumentNullException.ThrowIfNull(keySelector);
@@ -241,7 +241,7 @@ public static IAsyncEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
241241
public static IAsyncEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
242242
this IAsyncEnumerable<TSource> source,
243243
Func<TSource, TKey> keySelector,
244-
Func<TKey, IEnumerable<TSource>, TResult> resultSelector,
244+
Func<TKey, IReadOnlyList<TSource>, TResult> resultSelector,
245245
IEqualityComparer<TKey>? comparer)
246246
{
247247
ArgumentNullException.ThrowIfNull(source);

Source/SuperLinq.Async/PublicAPI/net6.0/PublicAPI.Unshipped.txt

Lines changed: 43 additions & 3 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/net7.0/PublicAPI.Unshipped.txt

Lines changed: 43 additions & 3 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 43 additions & 3 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt

Lines changed: 43 additions & 3 deletions
Large diffs are not rendered by default.

Source/SuperLinq.Async/Segment.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static partial class AsyncSuperEnumerable
1313
/// Thrown if either <paramref name="source"/> or <paramref name="newSegmentPredicate"/> are <see langword="null"/>.
1414
/// </exception>
1515

16-
public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, bool> newSegmentPredicate)
16+
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, bool> newSegmentPredicate)
1717
{
1818
ArgumentNullException.ThrowIfNull(source);
1919
ArgumentNullException.ThrowIfNull(newSegmentPredicate);
@@ -32,7 +32,7 @@ public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<
3232
/// Thrown if either <paramref name="source"/> or <paramref name="newSegmentPredicate"/> are <see langword="null"/>.
3333
/// </exception>
3434

35-
public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, ValueTask<bool>> newSegmentPredicate)
35+
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, ValueTask<bool>> newSegmentPredicate)
3636
{
3737
ArgumentNullException.ThrowIfNull(source);
3838
ArgumentNullException.ThrowIfNull(newSegmentPredicate);
@@ -51,7 +51,7 @@ public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<
5151
/// Thrown if either <paramref name="source"/> or <paramref name="newSegmentPredicate"/> are <see langword="null"/>.
5252
/// </exception>
5353

54-
public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, int, bool> newSegmentPredicate)
54+
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, int, bool> newSegmentPredicate)
5555
{
5656
ArgumentNullException.ThrowIfNull(source);
5757
ArgumentNullException.ThrowIfNull(newSegmentPredicate);
@@ -70,7 +70,7 @@ public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<
7070
/// Thrown if either <paramref name="source"/> or <paramref name="newSegmentPredicate"/> are <see langword="null"/>.
7171
/// </exception>
7272

73-
public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, int, ValueTask<bool>> newSegmentPredicate)
73+
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, int, ValueTask<bool>> newSegmentPredicate)
7474
{
7575
ArgumentNullException.ThrowIfNull(source);
7676
ArgumentNullException.ThrowIfNull(newSegmentPredicate);
@@ -89,7 +89,7 @@ public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<
8989
/// Thrown if either <paramref name="source"/> or <paramref name="newSegmentPredicate"/> are <see langword="null"/>.
9090
/// </exception>
9191

92-
public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, T, int, bool> newSegmentPredicate)
92+
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, T, int, bool> newSegmentPredicate)
9393
{
9494
ArgumentNullException.ThrowIfNull(source);
9595
ArgumentNullException.ThrowIfNull(newSegmentPredicate);
@@ -108,14 +108,14 @@ public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<
108108
/// Thrown if either <paramref name="source"/> or <paramref name="newSegmentPredicate"/> are <see langword="null"/>.
109109
/// </exception>
110110

111-
public static IAsyncEnumerable<IEnumerable<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, T, int, ValueTask<bool>> newSegmentPredicate)
111+
public static IAsyncEnumerable<IReadOnlyList<T>> Segment<T>(this IAsyncEnumerable<T> source, Func<T, T, int, ValueTask<bool>> newSegmentPredicate)
112112
{
113113
ArgumentNullException.ThrowIfNull(source);
114114
ArgumentNullException.ThrowIfNull(newSegmentPredicate);
115115

116116
return Core(source, newSegmentPredicate);
117117

118-
static async IAsyncEnumerable<IEnumerable<T>> Core(IAsyncEnumerable<T> source, Func<T, T, int, ValueTask<bool>> newSegmentPredicate, [EnumeratorCancellation] CancellationToken cancellationToken = default)
118+
static async IAsyncEnumerable<IReadOnlyList<T>> Core(IAsyncEnumerable<T> source, Func<T, T, int, ValueTask<bool>> newSegmentPredicate, [EnumeratorCancellation] CancellationToken cancellationToken = default)
119119
{
120120
await using var e = source.GetConfiguredAsyncEnumerator(cancellationToken);
121121

Source/SuperLinq.Async/Split.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static partial class AsyncSuperEnumerable
1111
/// <param name="separator">Separator element.</param>
1212
/// <returns>A sequence of splits of elements.</returns>
1313
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
14-
public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
14+
public static IAsyncEnumerable<IReadOnlyList<TSource>> Split<TSource>(
1515
this IAsyncEnumerable<TSource> source,
1616
TSource separator)
1717
{
@@ -28,7 +28,7 @@ public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
2828
/// <returns>A sequence of splits of elements.</returns>
2929
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
3030
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than 1.</exception>
31-
public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
31+
public static IAsyncEnumerable<IReadOnlyList<TSource>> Split<TSource>(
3232
this IAsyncEnumerable<TSource> source,
3333
TSource separator, int count)
3434
{
@@ -53,7 +53,7 @@ public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
5353
public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
5454
this IAsyncEnumerable<TSource> source,
5555
TSource separator,
56-
Func<IEnumerable<TSource>, TResult> resultSelector)
56+
Func<IReadOnlyList<TSource>, TResult> resultSelector)
5757
{
5858
return Split(source, separator, int.MaxValue, resultSelector);
5959
}
@@ -78,7 +78,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
7878
public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
7979
this IAsyncEnumerable<TSource> source,
8080
TSource separator, int count,
81-
Func<IEnumerable<TSource>, TResult> resultSelector)
81+
Func<IReadOnlyList<TSource>, TResult> resultSelector)
8282
{
8383
return Split(source, separator, null, count, resultSelector);
8484
}
@@ -94,7 +94,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
9494
/// element equality.</param>
9595
/// <returns>A sequence of splits of elements.</returns>
9696
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
97-
public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
97+
public static IAsyncEnumerable<IReadOnlyList<TSource>> Split<TSource>(
9898
this IAsyncEnumerable<TSource> source,
9999
TSource separator, IEqualityComparer<TSource>? comparer)
100100
{
@@ -115,7 +115,7 @@ public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
115115
/// <returns>A sequence of splits of elements.</returns>
116116
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
117117
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than 1.</exception>
118-
public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
118+
public static IAsyncEnumerable<IReadOnlyList<TSource>> Split<TSource>(
119119
this IAsyncEnumerable<TSource> source,
120120
TSource separator, IEqualityComparer<TSource>? comparer, int count)
121121
{
@@ -143,7 +143,7 @@ public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
143143
public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
144144
this IAsyncEnumerable<TSource> source,
145145
TSource separator, IEqualityComparer<TSource> comparer,
146-
Func<IEnumerable<TSource>, TResult> resultSelector)
146+
Func<IReadOnlyList<TSource>, TResult> resultSelector)
147147
{
148148
return Split(source, separator, comparer, int.MaxValue, resultSelector);
149149
}
@@ -171,7 +171,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
171171
public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
172172
this IAsyncEnumerable<TSource> source,
173173
TSource separator, IEqualityComparer<TSource>? comparer, int count,
174-
Func<IEnumerable<TSource>, TResult> resultSelector)
174+
Func<IReadOnlyList<TSource>, TResult> resultSelector)
175175
{
176176
ArgumentNullException.ThrowIfNull(source);
177177
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
@@ -192,7 +192,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
192192
/// <returns>A sequence of splits of elements.</returns>
193193
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
194194
/// <exception cref="ArgumentNullException"><paramref name="separatorFunc"/> is <see langword="null"/>.</exception>
195-
public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
195+
public static IAsyncEnumerable<IReadOnlyList<TSource>> Split<TSource>(
196196
this IAsyncEnumerable<TSource> source,
197197
Func<TSource, bool> separatorFunc)
198198
{
@@ -212,7 +212,7 @@ public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
212212
/// <exception cref="ArgumentNullException"><paramref name="source"/> is <see langword="null"/>.</exception>
213213
/// <exception cref="ArgumentNullException"><paramref name="separatorFunc"/> is <see langword="null"/>.</exception>
214214
/// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is less than 1.</exception>
215-
public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
215+
public static IAsyncEnumerable<IReadOnlyList<TSource>> Split<TSource>(
216216
this IAsyncEnumerable<TSource> source,
217217
Func<TSource, bool> separatorFunc, int count)
218218
{
@@ -239,7 +239,7 @@ public static IAsyncEnumerable<IEnumerable<TSource>> Split<TSource>(
239239
public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
240240
this IAsyncEnumerable<TSource> source,
241241
Func<TSource, bool> separatorFunc,
242-
Func<IEnumerable<TSource>, TResult> resultSelector)
242+
Func<IReadOnlyList<TSource>, TResult> resultSelector)
243243
{
244244
return Split(source, separatorFunc, int.MaxValue, resultSelector);
245245
}
@@ -267,7 +267,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
267267
public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
268268
this IAsyncEnumerable<TSource> source,
269269
Func<TSource, bool> separatorFunc, int count,
270-
Func<IEnumerable<TSource>, TResult> resultSelector)
270+
Func<IReadOnlyList<TSource>, TResult> resultSelector)
271271
{
272272
ArgumentNullException.ThrowIfNull(source);
273273
ArgumentNullException.ThrowIfNull(separatorFunc);
@@ -279,7 +279,7 @@ public static IAsyncEnumerable<TResult> Split<TSource, TResult>(
279279
static async IAsyncEnumerable<TResult> Core(
280280
IAsyncEnumerable<TSource> source,
281281
Func<TSource, bool> separatorFunc, int count,
282-
Func<IEnumerable<TSource>, TResult> resultSelector,
282+
Func<IReadOnlyList<TSource>, TResult> resultSelector,
283283
[EnumeratorCancellation] CancellationToken cancellationToken = default)
284284
{
285285
var items = new List<TSource>();

Source/SuperLinq/GroupAdjacent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public static IEnumerable<IGrouping<TKey, TElement>> GroupAdjacent<TSource, TKey
223223
public static IEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
224224
this IEnumerable<TSource> source,
225225
Func<TSource, TKey> keySelector,
226-
Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
226+
Func<TKey, IReadOnlyList<TSource>, TResult> resultSelector)
227227
{
228228
ArgumentNullException.ThrowIfNull(source);
229229
ArgumentNullException.ThrowIfNull(keySelector);
@@ -276,7 +276,7 @@ public static IEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
276276
public static IEnumerable<TResult> GroupAdjacent<TSource, TKey, TResult>(
277277
this IEnumerable<TSource> source,
278278
Func<TSource, TKey> keySelector,
279-
Func<TKey, IEnumerable<TSource>, TResult> resultSelector,
279+
Func<TKey, IReadOnlyList<TSource>, TResult> resultSelector,
280280
IEqualityComparer<TKey>? comparer)
281281
{
282282
ArgumentNullException.ThrowIfNull(source);

0 commit comments

Comments
 (0)