Improve Stacktrace Part2

master
neuecc 2020-05-13 11:36:33 +09:00
parent 8ff4de67a1
commit 79f770e687
66 changed files with 916 additions and 910 deletions

View File

@ -16,6 +16,7 @@
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\UnityEqualityComparer.cs; ..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\UnityEqualityComparer.cs;
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\DiagnosticsExtensions.cs; ..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\DiagnosticsExtensions.cs;
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\PlayerLoopRunner.cs; ..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\PlayerLoopRunner.cs;
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\ContinuationQueue.cs;
..\UniTask\Assets\Plugins\UniTask\Runtime\CancellationTokenSourceExtensions.cs; ..\UniTask\Assets\Plugins\UniTask\Runtime\CancellationTokenSourceExtensions.cs;
..\UniTask\Assets\Plugins\UniTask\Runtime\EnumeratorAsyncExtensions.cs; ..\UniTask\Assets\Plugins\UniTask\Runtime\EnumeratorAsyncExtensions.cs;

View File

@ -48,6 +48,8 @@ namespace NetCoreSandbox
) )
{ {
Console.WriteLine(item); Console.WriteLine(item);
} }

View File

@ -35,7 +35,7 @@ namespace NetCoreTests.Linq
xs.Should().Be(ys); xs.Should().Be(ys);
} }
{ {
var xs = await UniTaskAsyncEnumerable.Range(start, count).SumAwaitCancellationAsync((x, _) => UniTask.Run(() => x)); var xs = await UniTaskAsyncEnumerable.Range(start, count).SumAwaitWithCancellationAsync((x, _) => UniTask.Run(() => x));
var ys = Enumerable.Range(start, count).Sum(x => x); var ys = Enumerable.Range(start, count).Sum(x => x);
xs.Should().Be(ys); xs.Should().Be(ys);
} }

View File

@ -12,7 +12,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
return Aggregate.InvokeAsync(source, accumulator, cancellationToken); return Aggregate.AggregateAsync(source, accumulator, cancellationToken);
} }
public static UniTask<TAccumulate> AggregateAsync<TSource, TAccumulate>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, CancellationToken cancellationToken = default) public static UniTask<TAccumulate> AggregateAsync<TSource, TAccumulate>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, CancellationToken cancellationToken = default)
@ -20,7 +20,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
return Aggregate.InvokeAsync(source, seed, accumulator, cancellationToken); return Aggregate.AggregateAsync(source, seed, accumulator, cancellationToken);
} }
public static UniTask<TResult> AggregateAsync<TSource, TAccumulate, TResult>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken = default) public static UniTask<TResult> AggregateAsync<TSource, TAccumulate, TResult>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken = default)
@ -29,7 +29,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
Error.ThrowArgumentNullException(accumulator, nameof(resultSelector)); Error.ThrowArgumentNullException(accumulator, nameof(resultSelector));
return Aggregate.InvokeAsync(source, seed, accumulator, resultSelector, cancellationToken); return Aggregate.AggregateAsync(source, seed, accumulator, resultSelector, cancellationToken);
} }
public static UniTask<TSource> AggregateAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, UniTask<TSource>> accumulator, CancellationToken cancellationToken = default) public static UniTask<TSource> AggregateAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, UniTask<TSource>> accumulator, CancellationToken cancellationToken = default)
@ -37,7 +37,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
return Aggregate.InvokeAsync(source, accumulator, cancellationToken); return Aggregate.AggregateAwaitAsync(source, accumulator, cancellationToken);
} }
public static UniTask<TAccumulate> AggregateAwaitAsync<TSource, TAccumulate>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken = default) public static UniTask<TAccumulate> AggregateAwaitAsync<TSource, TAccumulate>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken = default)
@ -45,7 +45,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
return Aggregate.InvokeAsync(source, seed, accumulator, cancellationToken); return Aggregate.AggregateAwaitAsync(source, seed, accumulator, cancellationToken);
} }
public static UniTask<TResult> AggregateAwaitAsync<TSource, TAccumulate, TResult>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, Func<TAccumulate, UniTask<TResult>> resultSelector, CancellationToken cancellationToken = default) public static UniTask<TResult> AggregateAwaitAsync<TSource, TAccumulate, TResult>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, Func<TAccumulate, UniTask<TResult>> resultSelector, CancellationToken cancellationToken = default)
@ -54,7 +54,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
Error.ThrowArgumentNullException(accumulator, nameof(resultSelector)); Error.ThrowArgumentNullException(accumulator, nameof(resultSelector));
return Aggregate.InvokeAsync(source, seed, accumulator, resultSelector, cancellationToken); return Aggregate.AggregateAwaitAsync(source, seed, accumulator, resultSelector, cancellationToken);
} }
public static UniTask<TSource> AggregateAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, CancellationToken, UniTask<TSource>> accumulator, CancellationToken cancellationToken = default) public static UniTask<TSource> AggregateAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, CancellationToken, UniTask<TSource>> accumulator, CancellationToken cancellationToken = default)
@ -62,7 +62,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
return Aggregate.InvokeAsync(source, accumulator, cancellationToken); return Aggregate.AggregateAwaitWithCancellationAsync(source, accumulator, cancellationToken);
} }
public static UniTask<TAccumulate> AggregateAwaitWithCancellationAsync<TSource, TAccumulate>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken = default) public static UniTask<TAccumulate> AggregateAwaitWithCancellationAsync<TSource, TAccumulate>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken = default)
@ -70,7 +70,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
return Aggregate.InvokeAsync(source, seed, accumulator, cancellationToken); return Aggregate.AggregateAwaitWithCancellationAsync(source, seed, accumulator, cancellationToken);
} }
public static UniTask<TResult> AggregateAwaitWithCancellationAsync<TSource, TAccumulate, TResult>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, Func<TAccumulate, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken = default) public static UniTask<TResult> AggregateAwaitWithCancellationAsync<TSource, TAccumulate, TResult>(this IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, Func<TAccumulate, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken = default)
@ -79,13 +79,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(accumulator, nameof(accumulator)); Error.ThrowArgumentNullException(accumulator, nameof(accumulator));
Error.ThrowArgumentNullException(accumulator, nameof(resultSelector)); Error.ThrowArgumentNullException(accumulator, nameof(resultSelector));
return Aggregate.InvokeAsync(source, seed, accumulator, resultSelector, cancellationToken); return Aggregate.AggregateAwaitWithCancellationAsync(source, seed, accumulator, resultSelector, cancellationToken);
} }
} }
internal static class Aggregate internal static class Aggregate
{ {
internal static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator, CancellationToken cancellationToken) internal static async UniTask<TSource> AggregateAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> accumulator, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -116,7 +116,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<TAccumulate> InvokeAsync<TSource, TAccumulate>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, CancellationToken cancellationToken) internal static async UniTask<TAccumulate> AggregateAsync<TSource, TAccumulate>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -138,7 +138,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<TResult> InvokeAsync<TSource, TAccumulate, TResult>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken) internal static async UniTask<TResult> AggregateAsync<TSource, TAccumulate, TResult>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -162,7 +162,7 @@ namespace Cysharp.Threading.Tasks.Linq
// with async // with async
internal static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, UniTask<TSource>> accumulator, CancellationToken cancellationToken) internal static async UniTask<TSource> AggregateAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, UniTask<TSource>> accumulator, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -193,7 +193,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<TAccumulate> InvokeAsync<TSource, TAccumulate>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken) internal static async UniTask<TAccumulate> AggregateAwaitAsync<TSource, TAccumulate>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -215,7 +215,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<TResult> InvokeAsync<TSource, TAccumulate, TResult>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, Func<TAccumulate, UniTask<TResult>> resultSelector, CancellationToken cancellationToken) internal static async UniTask<TResult> AggregateAwaitAsync<TSource, TAccumulate, TResult>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, UniTask<TAccumulate>> accumulator, Func<TAccumulate, UniTask<TResult>> resultSelector, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -240,7 +240,7 @@ namespace Cysharp.Threading.Tasks.Linq
// with cancellation // with cancellation
internal static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, CancellationToken, UniTask<TSource>> accumulator, CancellationToken cancellationToken) internal static async UniTask<TSource> AggregateAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TSource, CancellationToken, UniTask<TSource>> accumulator, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -271,7 +271,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<TAccumulate> InvokeAsync<TSource, TAccumulate>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken) internal static async UniTask<TAccumulate> AggregateAwaitWithCancellationAsync<TSource, TAccumulate>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -293,7 +293,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<TResult> InvokeAsync<TSource, TAccumulate, TResult>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, Func<TAccumulate, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken) internal static async UniTask<TResult> AggregateAwaitWithCancellationAsync<TSource, TAccumulate, TResult>(IUniTaskAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, CancellationToken, UniTask<TAccumulate>> accumulator, Func<TAccumulate, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -11,7 +11,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return All.InvokeAsync(source, predicate, cancellationToken); return All.AllAsync(source, predicate, cancellationToken);
} }
public static UniTask<Boolean> AllAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<Boolean> AllAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -19,7 +19,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return All.InvokeAsync(source, predicate, cancellationToken); return All.AllAwaitAsync(source, predicate, cancellationToken);
} }
public static UniTask<Boolean> AllAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<Boolean> AllAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -27,13 +27,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return All.InvokeAsync(source, predicate, cancellationToken); return All.AllAwaitWithCancellationAsync(source, predicate, cancellationToken);
} }
} }
internal static class All internal static class All
{ {
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken) internal static async UniTask<bool> AllAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -57,7 +57,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<bool> AllAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -81,7 +81,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<bool> AllAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Any.InvokeAsync(source, cancellationToken); return Any.AnyAsync(source, cancellationToken);
} }
public static UniTask<Boolean> AnyAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<Boolean> AnyAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Any.InvokeAsync(source, predicate, cancellationToken); return Any.AnyAsync(source, predicate, cancellationToken);
} }
public static UniTask<Boolean> AnyAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<Boolean> AnyAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Any.InvokeAsync(source, predicate, cancellationToken); return Any.AnyAwaitAsync(source, predicate, cancellationToken);
} }
public static UniTask<Boolean> AnyAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<Boolean> AnyAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -34,13 +34,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Any.InvokeAsync(source, predicate, cancellationToken); return Any.AnyAwaitWithCancellationAsync(source, predicate, cancellationToken);
} }
} }
internal static class Any internal static class Any
{ {
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) internal static async UniTask<bool> AnyAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -61,7 +61,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken) internal static async UniTask<bool> AnyAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -85,7 +85,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<bool> AnyAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -109,7 +109,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<bool> AnyAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -36,10 +36,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, element, append, cancellationToken); return new _AppendPrepend(source, element, append, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _AppendPrepend : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
enum State : byte enum State : byte
{ {
@ -59,7 +59,7 @@ namespace Cysharp.Threading.Tasks.Linq
IUniTaskAsyncEnumerator<TSource> enumerator; IUniTaskAsyncEnumerator<TSource> enumerator;
UniTask<bool>.Awaiter awaiter; UniTask<bool>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, TSource element, bool append, CancellationToken cancellationToken) public _AppendPrepend(IUniTaskAsyncEnumerable<TSource> source, TSource element, bool append, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.element = element; this.element = element;
@ -108,7 +108,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_AppendPrepend)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<double> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
@ -26,22 +26,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAsync(this IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken = default) public static UniTask<double> AverageAsync(this IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<double> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken = default)
@ -49,7 +49,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
@ -57,22 +57,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<float> AverageAsync(this IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken = default) public static UniTask<float> AverageAsync(this IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<float> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken = default) public static UniTask<float> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken = default)
@ -80,7 +80,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<float> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken = default) public static UniTask<float> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken = default)
@ -88,22 +88,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<float> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken = default) public static UniTask<float> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAsync(this IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken = default) public static UniTask<double> AverageAsync(this IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<double> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken = default)
@ -111,7 +111,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken = default)
@ -119,22 +119,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<double> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken = default) public static UniTask<double> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<decimal> AverageAsync(this IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken = default) public static UniTask<decimal> AverageAsync(this IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<decimal> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken = default) public static UniTask<decimal> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken = default)
@ -142,7 +142,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<decimal> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken = default) public static UniTask<decimal> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
@ -150,22 +150,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<decimal> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken = default) public static UniTask<decimal> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAsync(this IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAsync(this IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<double?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken = default)
@ -173,7 +173,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
@ -181,22 +181,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAsync(this IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAsync(this IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<double?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken = default)
@ -204,7 +204,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
@ -212,22 +212,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<float?> AverageAsync(this IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken = default) public static UniTask<float?> AverageAsync(this IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<float?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken = default) public static UniTask<float?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken = default)
@ -235,7 +235,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<float?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken = default) public static UniTask<float?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
@ -243,22 +243,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<float?> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken = default) public static UniTask<float?> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAsync(this IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAsync(this IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<double?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken = default)
@ -266,7 +266,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
@ -274,22 +274,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<double?> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken = default) public static UniTask<double?> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<decimal?> AverageAsync(this IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken = default) public static UniTask<decimal?> AverageAsync(this IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<decimal?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken = default) public static UniTask<decimal?> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken = default)
@ -297,7 +297,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<decimal?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default) public static UniTask<decimal?> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
@ -305,22 +305,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<decimal?> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default) public static UniTask<decimal?> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
} }
internal static class Average internal static class Average
{ {
public static async UniTask<double> InvokeAsync(IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken) public static async UniTask<double> AverageAsync(IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32 sum = 0; Int32 sum = 0;
@ -348,7 +348,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32 sum = 0; Int32 sum = 0;
@ -376,7 +376,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32 sum = 0; Int32 sum = 0;
@ -404,7 +404,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32 sum = 0; Int32 sum = 0;
@ -432,7 +432,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync(IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken) public static async UniTask<double> AverageAsync(IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64 sum = 0; Int64 sum = 0;
@ -460,7 +460,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64 sum = 0; Int64 sum = 0;
@ -488,7 +488,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64 sum = 0; Int64 sum = 0;
@ -516,7 +516,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64 sum = 0; Int64 sum = 0;
@ -544,7 +544,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<float> InvokeAsync(IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken) public static async UniTask<float> AverageAsync(IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single sum = 0; Single sum = 0;
@ -572,7 +572,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<float> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken) public static async UniTask<float> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single sum = 0; Single sum = 0;
@ -600,7 +600,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<float> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken) public static async UniTask<float> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single sum = 0; Single sum = 0;
@ -628,7 +628,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<float> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken) public static async UniTask<float> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single sum = 0; Single sum = 0;
@ -656,7 +656,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<double> InvokeAsync(IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken) public static async UniTask<double> AverageAsync(IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double sum = 0; Double sum = 0;
@ -684,7 +684,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double sum = 0; Double sum = 0;
@ -712,7 +712,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double sum = 0; Double sum = 0;
@ -740,7 +740,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken) public static async UniTask<double> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double sum = 0; Double sum = 0;
@ -768,7 +768,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal> InvokeAsync(IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken) public static async UniTask<decimal> AverageAsync(IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal sum = 0; Decimal sum = 0;
@ -796,7 +796,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken) public static async UniTask<decimal> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal sum = 0; Decimal sum = 0;
@ -824,7 +824,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken) public static async UniTask<decimal> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal sum = 0; Decimal sum = 0;
@ -852,7 +852,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken) public static async UniTask<decimal> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal sum = 0; Decimal sum = 0;
@ -880,7 +880,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double?> InvokeAsync(IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken) public static async UniTask<double?> AverageAsync(IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32? sum = 0; Int32? sum = 0;
@ -912,7 +912,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32? sum = 0; Int32? sum = 0;
@ -944,7 +944,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32? sum = 0; Int32? sum = 0;
@ -976,7 +976,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int32? sum = 0; Int32? sum = 0;
@ -1008,7 +1008,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync(IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken) public static async UniTask<double?> AverageAsync(IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64? sum = 0; Int64? sum = 0;
@ -1040,7 +1040,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64? sum = 0; Int64? sum = 0;
@ -1072,7 +1072,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64? sum = 0; Int64? sum = 0;
@ -1104,7 +1104,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Int64? sum = 0; Int64? sum = 0;
@ -1136,7 +1136,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (double)sum / count; return (double)sum / count;
} }
public static async UniTask<float?> InvokeAsync(IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken) public static async UniTask<float?> AverageAsync(IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single? sum = 0; Single? sum = 0;
@ -1168,7 +1168,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<float?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken) public static async UniTask<float?> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single? sum = 0; Single? sum = 0;
@ -1200,7 +1200,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<float?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken) public static async UniTask<float?> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single? sum = 0; Single? sum = 0;
@ -1232,7 +1232,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<float?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken) public static async UniTask<float?> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Single? sum = 0; Single? sum = 0;
@ -1264,7 +1264,7 @@ namespace Cysharp.Threading.Tasks.Linq
return (float)(sum / count); return (float)(sum / count);
} }
public static async UniTask<double?> InvokeAsync(IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken) public static async UniTask<double?> AverageAsync(IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double? sum = 0; Double? sum = 0;
@ -1296,7 +1296,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double? sum = 0; Double? sum = 0;
@ -1328,7 +1328,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double? sum = 0; Double? sum = 0;
@ -1360,7 +1360,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken) public static async UniTask<double?> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Double? sum = 0; Double? sum = 0;
@ -1392,7 +1392,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal?> InvokeAsync(IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken) public static async UniTask<decimal?> AverageAsync(IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal? sum = 0; Decimal? sum = 0;
@ -1424,7 +1424,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken) public static async UniTask<decimal?> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal? sum = 0; Decimal? sum = 0;
@ -1456,7 +1456,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken) public static async UniTask<decimal?> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal? sum = 0; Decimal? sum = 0;
@ -1488,7 +1488,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum / count; return sum / count;
} }
public static async UniTask<decimal?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken) public static async UniTask<decimal?> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
Decimal? sum = 0; Decimal? sum = 0;

View File

@ -39,7 +39,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Average.InvokeAsync(source, cancellationToken); return Average.AverageAsync(source, cancellationToken);
} }
public static UniTask<<#= ret #>> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= ret #>> AverageAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken = default)
@ -47,7 +47,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAsync(source, selector, cancellationToken);
} }
public static UniTask<<#= ret #>> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= ret #>> AverageAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default)
@ -55,15 +55,15 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<<#= ret #>> AverageAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= ret #>> AverageAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Average.InvokeAsync(source, selector, cancellationToken); return Average.AverageAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
<# } #> <# } #>
@ -72,7 +72,7 @@ namespace Cysharp.Threading.Tasks.Linq
internal static class Average internal static class Average
{ {
<# foreach(var (t, ret) in types) { #> <# foreach(var (t, ret) in types) { #>
public static async UniTask<<#= ret #>> InvokeAsync(IUniTaskAsyncEnumerable<<#= TypeName(t) #>> source, CancellationToken cancellationToken) public static async UniTask<<#= ret #>> AverageAsync(IUniTaskAsyncEnumerable<<#= TypeName(t) #>> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
<#= TypeName(t) #> sum = 0; <#= TypeName(t) #> sum = 0;
@ -112,7 +112,7 @@ namespace Cysharp.Threading.Tasks.Linq
return <#= CalcResult(t) #>; return <#= CalcResult(t) #>;
} }
public static async UniTask<<#= ret #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken) public static async UniTask<<#= ret #>> AverageAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
<#= TypeName(t) #> sum = 0; <#= TypeName(t) #> sum = 0;
@ -152,7 +152,7 @@ namespace Cysharp.Threading.Tasks.Linq
return <#= CalcResult(t) #>; return <#= CalcResult(t) #>;
} }
public static async UniTask<<#= ret #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken) public static async UniTask<<#= ret #>> AverageAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
<#= TypeName(t) #> sum = 0; <#= TypeName(t) #> sum = 0;
@ -192,7 +192,7 @@ namespace Cysharp.Threading.Tasks.Linq
return <#= CalcResult(t) #>; return <#= CalcResult(t) #>;
} }
public static async UniTask<<#= ret #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken) public static async UniTask<<#= ret #>> AverageAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
<#= TypeName(t) #> sum = 0; <#= TypeName(t) #> sum = 0;

View File

@ -38,10 +38,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<IList<TSource>> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<IList<TSource>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, count, cancellationToken); return new _Buffer(source, count, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<IList<TSource>> sealed class _Buffer : MoveNextSource, IUniTaskAsyncEnumerator<IList<TSource>>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -56,7 +56,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool completed; bool completed;
List<TSource> buffer; List<TSource> buffer;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken) public _Buffer(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.count = count; this.count = count;
@ -128,7 +128,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_Buffer)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -191,10 +191,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<IList<TSource>> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<IList<TSource>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, count, skip, cancellationToken); return new _BufferSkip(source, count, skip, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<IList<TSource>> sealed class _BufferSkip : MoveNextSource, IUniTaskAsyncEnumerator<IList<TSource>>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -211,7 +211,7 @@ namespace Cysharp.Threading.Tasks.Linq
Queue<List<TSource>> buffers; Queue<List<TSource>> buffers;
int index = 0; int index = 0;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, int count, int skip, CancellationToken cancellationToken) public _BufferSkip(IUniTaskAsyncEnumerable<TSource> source, int count, int skip, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.count = count; this.count = count;
@ -282,7 +282,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_BufferSkip)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -25,12 +25,12 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _Cast(source, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<object, TResult> class _Cast : AsyncEnumeratorBase<object, TResult>
{ {
public Enumerator(IUniTaskAsyncEnumerable<object> source, CancellationToken cancellationToken) public _Cast(IUniTaskAsyncEnumerable<object> source, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {

View File

@ -28,10 +28,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(first, second, cancellationToken); return new _Concat(first, second, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _Concat : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -51,7 +51,7 @@ namespace Cysharp.Threading.Tasks.Linq
IUniTaskAsyncEnumerator<TSource> enumerator; IUniTaskAsyncEnumerator<TSource> enumerator;
UniTask<bool>.Awaiter awaiter; UniTask<bool>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, CancellationToken cancellationToken) public _Concat(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, CancellationToken cancellationToken)
{ {
this.first = first; this.first = first;
this.second = second; this.second = second;
@ -108,7 +108,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_Concat)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -17,13 +17,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return Contains.InvokeAsync(source, value, comparer, cancellationToken); return Contains.ContainsAsync(source, value, comparer, cancellationToken);
} }
} }
internal static class Contains internal static class Contains
{ {
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) internal static async UniTask<bool> ContainsAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Count.InvokeAsync(source, cancellationToken); return Count.CountAsync(source, cancellationToken);
} }
public static UniTask<Int32> CountAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<Int32> CountAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Count.InvokeAsync(source, predicate, cancellationToken); return Count.CountAsync(source, predicate, cancellationToken);
} }
public static UniTask<Int32> CountAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<Int32> CountAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Count.InvokeAsync(source, predicate, cancellationToken); return Count.CountAwaitAsync(source, predicate, cancellationToken);
} }
public static UniTask<Int32> CountAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<Int32> CountAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -34,13 +34,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Count.InvokeAsync(source, predicate, cancellationToken); return Count.CountAwaitWithCancellationAsync(source, predicate, cancellationToken);
} }
} }
internal static class Count internal static class Count
{ {
internal static async UniTask<int> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) internal static async UniTask<int> CountAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
var count = 0; var count = 0;
@ -63,7 +63,7 @@ namespace Cysharp.Threading.Tasks.Linq
return count; return count;
} }
internal static async UniTask<int> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken) internal static async UniTask<int> CountAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken)
{ {
var count = 0; var count = 0;
@ -89,7 +89,7 @@ namespace Cysharp.Threading.Tasks.Linq
return count; return count;
} }
internal static async UniTask<int> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<int> CountAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
var count = 0; var count = 0;
@ -115,7 +115,7 @@ namespace Cysharp.Threading.Tasks.Linq
return count; return count;
} }
internal static async UniTask<int> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<int> CountAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
var count = 0; var count = 0;

View File

@ -34,10 +34,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, defaultValue, cancellationToken); return new _DefaultIfEmpty(source, defaultValue, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _DefaultIfEmpty : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
enum IteratingState : byte enum IteratingState : byte
{ {
@ -56,7 +56,7 @@ namespace Cysharp.Threading.Tasks.Linq
IUniTaskAsyncEnumerator<TSource> enumerator; IUniTaskAsyncEnumerator<TSource> enumerator;
UniTask<bool>.Awaiter awaiter; UniTask<bool>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, TSource defaultValue, CancellationToken cancellationToken) public _DefaultIfEmpty(IUniTaskAsyncEnumerable<TSource> source, TSource defaultValue, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
@ -99,7 +99,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_DefaultIfEmpty)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -59,7 +59,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return new DistinctAwaitCancellation<TSource, TKey>(source, keySelector, comparer); return new DistinctAwaitWithCancellation<TSource, TKey>(source, keySelector, comparer);
} }
} }
@ -76,14 +76,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, comparer, cancellationToken); return new _Distinct(source, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _Distinct : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly HashSet<TSource> set; readonly HashSet<TSource> set;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) public _Distinct(IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -129,15 +129,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, comparer, cancellationToken); return new _Distinct(source, keySelector, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _Distinct : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly HashSet<TKey> set; readonly HashSet<TKey> set;
readonly Func<TSource, TKey> keySelector; readonly Func<TSource, TKey> keySelector;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _Distinct(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -184,15 +184,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, comparer, cancellationToken); return new _DistinctAwait(source, keySelector, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey> class _DistinctAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey>
{ {
readonly HashSet<TKey> set; readonly HashSet<TKey> set;
readonly Func<TSource, UniTask<TKey>> keySelector; readonly Func<TSource, UniTask<TKey>> keySelector;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _DistinctAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -222,13 +222,13 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class DistinctAwaitCancellation<TSource, TKey> : IUniTaskAsyncEnumerable<TSource> internal sealed class DistinctAwaitWithCancellation<TSource, TKey> : IUniTaskAsyncEnumerable<TSource>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector; readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector;
readonly IEqualityComparer<TKey> comparer; readonly IEqualityComparer<TKey> comparer;
public DistinctAwaitCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer) public DistinctAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -237,15 +237,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, comparer, cancellationToken); return new _DistinctAwaitWithCancellation(source, keySelector, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey> class _DistinctAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey>
{ {
readonly HashSet<TKey> set; readonly HashSet<TKey> set;
readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector; readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _DistinctAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {

View File

@ -59,7 +59,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return new DistinctUntilChangedAwaitCancellation<TSource, TKey>(source, keySelector, comparer); return new DistinctUntilChangedAwaitWithCancellation<TSource, TKey>(source, keySelector, comparer);
} }
} }
@ -76,16 +76,16 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, comparer, cancellationToken); return new _DistinctUntilChanged(source, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _DistinctUntilChanged : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly IEqualityComparer<TSource> comparer; readonly IEqualityComparer<TSource> comparer;
TSource prev; TSource prev;
bool first; bool first;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) public _DistinctUntilChanged(IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -133,17 +133,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, comparer, cancellationToken); return new _DistinctUntilChanged(source, keySelector, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _DistinctUntilChanged : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly IEqualityComparer<TKey> comparer; readonly IEqualityComparer<TKey> comparer;
readonly Func<TSource, TKey> keySelector; readonly Func<TSource, TKey> keySelector;
TKey prev; TKey prev;
bool first; bool first;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _DistinctUntilChanged(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -194,17 +194,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, comparer, cancellationToken); return new _DistinctUntilChangedAwait(source, keySelector, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey> class _DistinctUntilChangedAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey>
{ {
readonly IEqualityComparer<TKey> comparer; readonly IEqualityComparer<TKey> comparer;
readonly Func<TSource, UniTask<TKey>> keySelector; readonly Func<TSource, UniTask<TKey>> keySelector;
TKey prev; TKey prev;
bool first; bool first;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _DistinctUntilChangedAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -237,13 +237,13 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class DistinctUntilChangedAwaitCancellation<TSource, TKey> : IUniTaskAsyncEnumerable<TSource> internal sealed class DistinctUntilChangedAwaitWithCancellation<TSource, TKey> : IUniTaskAsyncEnumerable<TSource>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector; readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector;
readonly IEqualityComparer<TKey> comparer; readonly IEqualityComparer<TKey> comparer;
public DistinctUntilChangedAwaitCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer) public DistinctUntilChangedAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -252,17 +252,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, comparer, cancellationToken); return new _DistinctUntilChangedAwaitWithCancellation(source, keySelector, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey> class _DistinctUntilChangedAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, TKey>
{ {
readonly IEqualityComparer<TKey> comparer; readonly IEqualityComparer<TKey> comparer;
readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector; readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector;
TKey prev; TKey prev;
bool first; bool first;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _DistinctUntilChangedAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {

View File

@ -101,10 +101,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, onNext, onError, onCompleted, cancellationToken); return new _Do(source, onNext, onError, onCompleted, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _Do : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -117,7 +117,7 @@ namespace Cysharp.Threading.Tasks.Linq
IUniTaskAsyncEnumerator<TSource> enumerator; IUniTaskAsyncEnumerator<TSource> enumerator;
UniTask<bool>.Awaiter awaiter; UniTask<bool>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted, CancellationToken cancellationToken) public _Do(IUniTaskAsyncEnumerable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.onNext = onNext; this.onNext = onNext;
@ -199,7 +199,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_Do)state;
if (self.TryGetResultWithNotification(self.awaiter, out var result)) if (self.TryGetResultWithNotification(self.awaiter, out var result))
{ {

View File

@ -10,20 +10,20 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return ElementAt.InvokeAsync(source, index, cancellationToken, false); return ElementAt.ElementAtAsync(source, index, cancellationToken, false);
} }
public static UniTask<TSource> ElementAtOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken = default) public static UniTask<TSource> ElementAtOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return ElementAt.InvokeAsync(source, index, cancellationToken, true); return ElementAt.ElementAtAsync(source, index, cancellationToken, true);
} }
} }
internal static class ElementAt internal static class ElementAt
{ {
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> ElementAtAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, int index, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -20,14 +20,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return Enumerator.Instance; return _Empty.Instance;
} }
class Enumerator : IUniTaskAsyncEnumerator<T> class _Empty : IUniTaskAsyncEnumerator<T>
{ {
public static readonly IUniTaskAsyncEnumerator<T> Instance = new Enumerator(); public static readonly IUniTaskAsyncEnumerator<T> Instance = new _Empty();
Enumerator() _Empty()
{ {
} }

View File

@ -40,10 +40,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(first, second, comparer, cancellationToken); return new _Except(first, second, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _Except : AsyncEnumeratorBase<TSource, TSource>
{ {
static Action<object> HashSetAsyncCoreDelegate = HashSetAsyncCore; static Action<object> HashSetAsyncCoreDelegate = HashSetAsyncCore;
@ -53,7 +53,7 @@ namespace Cysharp.Threading.Tasks.Linq
HashSet<TSource> set; HashSet<TSource> set;
UniTask<HashSet<TSource>>.Awaiter awaiter; UniTask<HashSet<TSource>>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) public _Except(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
: base(first, cancellationToken) : base(first, cancellationToken)
{ {
@ -81,7 +81,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void HashSetAsyncCore(object state) static void HashSetAsyncCore(object state)
{ {
var self = (Enumerator)state; var self = (_Except)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return First.InvokeAsync(source, cancellationToken, false); return First.FirstAsync(source, cancellationToken, false);
} }
public static UniTask<TSource> FirstAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return First.InvokeAsync(source, predicate, cancellationToken, false); return First.FirstAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> FirstAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return First.InvokeAsync(source, predicate, cancellationToken, false); return First.FirstAwaitAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> FirstAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -34,14 +34,14 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return First.InvokeAsync(source, predicate, cancellationToken, false); return First.FirstAwaitWithCancellationAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> FirstOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return First.InvokeAsync(source, cancellationToken, true); return First.FirstAsync(source, cancellationToken, true);
} }
public static UniTask<TSource> FirstOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -49,7 +49,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return First.InvokeAsync(source, predicate, cancellationToken, true); return First.FirstAsync(source, predicate, cancellationToken, true);
} }
public static UniTask<TSource> FirstOrDefaultAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstOrDefaultAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -57,7 +57,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return First.InvokeAsync(source, predicate, cancellationToken, true); return First.FirstAwaitAsync(source, predicate, cancellationToken, true);
} }
public static UniTask<TSource> FirstOrDefaultAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> FirstOrDefaultAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -65,13 +65,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return First.InvokeAsync(source, predicate, cancellationToken, true); return First.FirstAwaitWithCancellationAsync(source, predicate, cancellationToken, true);
} }
} }
internal static class First internal static class First
{ {
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> FirstAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -101,7 +101,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> FirstAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -133,7 +133,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> FirstAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -165,7 +165,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> FirstAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -11,7 +11,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(action, nameof(action)); Error.ThrowArgumentNullException(action, nameof(action));
return Cysharp.Threading.Tasks.Linq.ForEach.InvokeAsync(source, action, cancellationToken); return Cysharp.Threading.Tasks.Linq.ForEach.ForEachAsync(source, action, cancellationToken);
} }
public static UniTask ForEachAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Action<TSource, Int32> action, CancellationToken cancellationToken = default) public static UniTask ForEachAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Action<TSource, Int32> action, CancellationToken cancellationToken = default)
@ -19,7 +19,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(action, nameof(action)); Error.ThrowArgumentNullException(action, nameof(action));
return Cysharp.Threading.Tasks.Linq.ForEach.InvokeAsync(source, action, cancellationToken); return Cysharp.Threading.Tasks.Linq.ForEach.ForEachAsync(source, action, cancellationToken);
} }
public static UniTask ForEachAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask> action, CancellationToken cancellationToken = default) public static UniTask ForEachAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask> action, CancellationToken cancellationToken = default)
@ -27,7 +27,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(action, nameof(action)); Error.ThrowArgumentNullException(action, nameof(action));
return Cysharp.Threading.Tasks.Linq.ForEach.InvokeAwaitAsync(source, action, cancellationToken); return Cysharp.Threading.Tasks.Linq.ForEach.ForEachAwaitAsync(source, action, cancellationToken);
} }
public static UniTask ForEachAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, UniTask> action, CancellationToken cancellationToken = default) public static UniTask ForEachAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, UniTask> action, CancellationToken cancellationToken = default)
@ -35,7 +35,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(action, nameof(action)); Error.ThrowArgumentNullException(action, nameof(action));
return Cysharp.Threading.Tasks.Linq.ForEach.InvokeAwaitAsync(source, action, cancellationToken); return Cysharp.Threading.Tasks.Linq.ForEach.ForEachAwaitAsync(source, action, cancellationToken);
} }
public static UniTask ForEachAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask> action, CancellationToken cancellationToken = default) public static UniTask ForEachAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask> action, CancellationToken cancellationToken = default)
@ -43,7 +43,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(action, nameof(action)); Error.ThrowArgumentNullException(action, nameof(action));
return Cysharp.Threading.Tasks.Linq.ForEach.InvokeAwaitWithCancellationAsync(source, action, cancellationToken); return Cysharp.Threading.Tasks.Linq.ForEach.ForEachAwaitWithCancellationAsync(source, action, cancellationToken);
} }
public static UniTask ForEachAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask> action, CancellationToken cancellationToken = default) public static UniTask ForEachAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask> action, CancellationToken cancellationToken = default)
@ -51,13 +51,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(action, nameof(action)); Error.ThrowArgumentNullException(action, nameof(action));
return Cysharp.Threading.Tasks.Linq.ForEach.InvokeAwaitWithCancellationAsync(source, action, cancellationToken); return Cysharp.Threading.Tasks.Linq.ForEach.ForEachAwaitWithCancellationAsync(source, action, cancellationToken);
} }
} }
internal static class ForEach internal static class ForEach
{ {
public static async UniTask InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Action<TSource> action, CancellationToken cancellationToken) public static async UniTask ForEachAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Action<TSource> action, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -76,7 +76,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Action<TSource, Int32> action, CancellationToken cancellationToken) public static async UniTask ForEachAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Action<TSource, Int32> action, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -96,7 +96,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask InvokeAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask> action, CancellationToken cancellationToken) public static async UniTask ForEachAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask> action, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -115,7 +115,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask InvokeAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, UniTask> action, CancellationToken cancellationToken) public static async UniTask ForEachAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, UniTask> action, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -135,7 +135,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask InvokeAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask> action, CancellationToken cancellationToken) public static async UniTask ForEachAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask> action, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -154,7 +154,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask InvokeAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask> action, CancellationToken cancellationToken) public static async UniTask ForEachAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask> action, CancellationToken cancellationToken)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -235,10 +235,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, elementSelector, comparer, cancellationToken); return new _GroupBy(source, keySelector, elementSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> sealed class _GroupBy : MoveNextSource, IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, TKey> keySelector; readonly Func<TSource, TKey> keySelector;
@ -248,7 +248,7 @@ namespace Cysharp.Threading.Tasks.Linq
IEnumerator<IGrouping<TKey, TElement>> groupEnumerator; IEnumerator<IGrouping<TKey, TElement>> groupEnumerator;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupBy(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -342,10 +342,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, elementSelector, resultSelector, comparer, cancellationToken); return new _GroupBy(source, keySelector, elementSelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _GroupBy : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, TKey> keySelector; readonly Func<TSource, TKey> keySelector;
@ -356,7 +356,7 @@ namespace Cysharp.Threading.Tasks.Linq
IEnumerator<IGrouping<TKey, TElement>> groupEnumerator; IEnumerator<IGrouping<TKey, TElement>> groupEnumerator;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupBy(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -450,10 +450,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, elementSelector, comparer, cancellationToken); return new _GroupByAwait(source, keySelector, elementSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> sealed class _GroupByAwait : MoveNextSource, IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, UniTask<TKey>> keySelector; readonly Func<TSource, UniTask<TKey>> keySelector;
@ -463,7 +463,7 @@ namespace Cysharp.Threading.Tasks.Linq
IEnumerator<IGrouping<TKey, TElement>> groupEnumerator; IEnumerator<IGrouping<TKey, TElement>> groupEnumerator;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupByAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -557,10 +557,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, elementSelector, resultSelector, comparer, cancellationToken); return new _GroupByAwait(source, keySelector, elementSelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _GroupByAwait : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore; readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore;
@ -574,7 +574,7 @@ namespace Cysharp.Threading.Tasks.Linq
IEnumerator<IGrouping<TKey, TElement>> groupEnumerator; IEnumerator<IGrouping<TKey, TElement>> groupEnumerator;
UniTask<TResult>.Awaiter awaiter; UniTask<TResult>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, Func<TKey, IEnumerable<TElement>, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupByAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, Func<TKey, IEnumerable<TElement>, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -650,7 +650,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectCore(object state) static void ResultSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupByAwait)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -688,10 +688,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, elementSelector, comparer, cancellationToken); return new _GroupByAwaitWithCancellation(source, keySelector, elementSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>> sealed class _GroupByAwaitWithCancellation : MoveNextSource, IUniTaskAsyncEnumerator<IGrouping<TKey, TElement>>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector; readonly Func<TSource, CancellationToken, UniTask<TKey>> keySelector;
@ -701,7 +701,7 @@ namespace Cysharp.Threading.Tasks.Linq
IEnumerator<IGrouping<TKey, TElement>> groupEnumerator; IEnumerator<IGrouping<TKey, TElement>> groupEnumerator;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupByAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -795,10 +795,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, keySelector, elementSelector, resultSelector, comparer, cancellationToken); return new _GroupByAwaitWithCancellation(source, keySelector, elementSelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _GroupByAwaitWithCancellation : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore; readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore;
@ -812,7 +812,7 @@ namespace Cysharp.Threading.Tasks.Linq
IEnumerator<IGrouping<TKey, TElement>> groupEnumerator; IEnumerator<IGrouping<TKey, TElement>> groupEnumerator;
UniTask<TResult>.Awaiter awaiter; UniTask<TResult>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, Func<TKey, IEnumerable<TElement>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupByAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, Func<TKey, IEnumerable<TElement>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.keySelector = keySelector; this.keySelector = keySelector;
@ -888,7 +888,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectCore(object state) static void ResultSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupByAwaitWithCancellation)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -62,7 +62,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(innerKeySelector, nameof(innerKeySelector)); Error.ThrowArgumentNullException(innerKeySelector, nameof(innerKeySelector));
Error.ThrowArgumentNullException(resultSelector, nameof(resultSelector)); Error.ThrowArgumentNullException(resultSelector, nameof(resultSelector));
return new GroupJoinWithCancellationAwait<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default); return new GroupJoinAwaitWithCancellation<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer<TKey>.Default);
} }
public static IUniTaskAsyncEnumerable<TResult> GroupJoinAwaitWithCancellation<TOuter, TInner, TKey, TResult>(this IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer) public static IUniTaskAsyncEnumerable<TResult> GroupJoinAwaitWithCancellation<TOuter, TInner, TKey, TResult>(this IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
@ -74,7 +74,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(resultSelector, nameof(resultSelector)); Error.ThrowArgumentNullException(resultSelector, nameof(resultSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return new GroupJoinWithCancellationAwait<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); return new GroupJoinAwaitWithCancellation<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
} }
} }
@ -100,10 +100,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken); return new _GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _GroupJoin : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -120,7 +120,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<bool>.Awaiter awaiter; UniTask<bool>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupJoin(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -186,7 +186,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoin)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -239,10 +239,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken); return new _GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _GroupJoinAwait : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore; readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore;
@ -264,7 +264,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<TResult>.Awaiter resultAwaiter; UniTask<TResult>.Awaiter resultAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, UniTask<TKey>> outerKeySelector, Func<TInner, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupJoinAwait(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, UniTask<TKey>> outerKeySelector, Func<TInner, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -330,7 +330,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoinAwait)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -364,7 +364,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void OuterKeySelectCore(object state) static void OuterKeySelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoinAwait)state;
if (self.TryGetResult(self.outerKeyAwaiter, out var result)) if (self.TryGetResult(self.outerKeyAwaiter, out var result))
{ {
@ -390,7 +390,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectCore(object state) static void ResultSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoinAwait)state;
if (self.TryGetResult(self.resultAwaiter, out var result)) if (self.TryGetResult(self.resultAwaiter, out var result))
{ {
@ -411,7 +411,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class GroupJoinWithCancellationAwait<TOuter, TInner, TKey, TResult> : IUniTaskAsyncEnumerable<TResult> internal sealed class GroupJoinAwaitWithCancellation<TOuter, TInner, TKey, TResult> : IUniTaskAsyncEnumerable<TResult>
{ {
readonly IUniTaskAsyncEnumerable<TOuter> outer; readonly IUniTaskAsyncEnumerable<TOuter> outer;
readonly IUniTaskAsyncEnumerable<TInner> inner; readonly IUniTaskAsyncEnumerable<TInner> inner;
@ -420,7 +420,7 @@ namespace Cysharp.Threading.Tasks.Linq
readonly Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector; readonly Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector;
readonly IEqualityComparer<TKey> comparer; readonly IEqualityComparer<TKey> comparer;
public GroupJoinWithCancellationAwait(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer) public GroupJoinAwaitWithCancellation(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -432,10 +432,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken); return new _GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _GroupJoinAwaitWithCancellation : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore; readonly static Action<object> ResultSelectCoreDelegate = ResultSelectCore;
@ -457,7 +457,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<TResult>.Awaiter resultAwaiter; UniTask<TResult>.Awaiter resultAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _GroupJoinAwaitWithCancellation(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, IEnumerable<TInner>, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -523,7 +523,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoinAwaitWithCancellation)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -557,7 +557,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void OuterKeySelectCore(object state) static void OuterKeySelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoinAwaitWithCancellation)state;
if (self.TryGetResult(self.outerKeyAwaiter, out var result)) if (self.TryGetResult(self.outerKeyAwaiter, out var result))
{ {
@ -583,7 +583,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectCore(object state) static void ResultSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_GroupJoinAwaitWithCancellation)state;
if (self.TryGetResult(self.resultAwaiter, out var result)) if (self.TryGetResult(self.resultAwaiter, out var result))
{ {

View File

@ -40,10 +40,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(first, second, comparer, cancellationToken); return new _Intersect(first, second, comparer, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _Intersect : AsyncEnumeratorBase<TSource, TSource>
{ {
static Action<object> HashSetAsyncCoreDelegate = HashSetAsyncCore; static Action<object> HashSetAsyncCoreDelegate = HashSetAsyncCore;
@ -53,7 +53,7 @@ namespace Cysharp.Threading.Tasks.Linq
HashSet<TSource> set; HashSet<TSource> set;
UniTask<HashSet<TSource>>.Awaiter awaiter; UniTask<HashSet<TSource>>.Awaiter awaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) public _Intersect(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
: base(first, cancellationToken) : base(first, cancellationToken)
{ {
@ -81,7 +81,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void HashSetAsyncCore(object state) static void HashSetAsyncCore(object state)
{ {
var self = (Enumerator)state; var self = (_Intersect)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -99,10 +99,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken); return new _Join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _Join : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -122,7 +122,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool continueNext; bool continueNext;
public Enumerator(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _Join(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -215,7 +215,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_Join)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -284,10 +284,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken); return new _JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _JoinAwait : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
static readonly Action<object> OuterSelectCoreDelegate = OuterSelectCore; static readonly Action<object> OuterSelectCoreDelegate = OuterSelectCore;
@ -312,7 +312,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool continueNext; bool continueNext;
public Enumerator(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, UniTask<TKey>> outerKeySelector, Func<TInner, UniTask<TKey>> innerKeySelector, Func<TOuter, TInner, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _JoinAwait(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, UniTask<TKey>> outerKeySelector, Func<TInner, UniTask<TKey>> innerKeySelector, Func<TOuter, TInner, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -408,7 +408,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_JoinAwait)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -442,7 +442,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void OuterSelectCore(object state) static void OuterSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_JoinAwait)state;
if (self.TryGetResult(self.outerKeyAwaiter, out var key)) if (self.TryGetResult(self.outerKeyAwaiter, out var key))
{ {
@ -465,7 +465,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectCore(object state) static void ResultSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_JoinAwait)state;
if (self.TryGetResult(self.resultAwaiter, out var result)) if (self.TryGetResult(self.resultAwaiter, out var result))
{ {
@ -512,10 +512,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken); return new _JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _JoinAwaitWithCancellation : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
static readonly Action<object> OuterSelectCoreDelegate = OuterSelectCore; static readonly Action<object> OuterSelectCoreDelegate = OuterSelectCore;
@ -540,7 +540,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool continueNext; bool continueNext;
public Enumerator(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, TInner, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) public _JoinAwaitWithCancellation(IUniTaskAsyncEnumerable<TOuter> outer, IUniTaskAsyncEnumerable<TInner> inner, Func<TOuter, CancellationToken, UniTask<TKey>> outerKeySelector, Func<TInner, CancellationToken, UniTask<TKey>> innerKeySelector, Func<TOuter, TInner, CancellationToken, UniTask<TResult>> resultSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
this.outer = outer; this.outer = outer;
this.inner = inner; this.inner = inner;
@ -636,7 +636,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_JoinAwaitWithCancellation)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {
@ -670,7 +670,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void OuterSelectCore(object state) static void OuterSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_JoinAwaitWithCancellation)state;
if (self.TryGetResult(self.outerKeyAwaiter, out var key)) if (self.TryGetResult(self.outerKeyAwaiter, out var key))
{ {
@ -693,7 +693,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectCore(object state) static void ResultSelectCore(object state)
{ {
var self = (Enumerator)state; var self = (_JoinAwaitWithCancellation)state;
if (self.TryGetResult(self.resultAwaiter, out var result)) if (self.TryGetResult(self.resultAwaiter, out var result))
{ {

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Last.InvokeAsync(source, cancellationToken, false); return Last.LastAsync(source, cancellationToken, false);
} }
public static UniTask<TSource> LastAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> LastAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Last.InvokeAsync(source, predicate, cancellationToken, false); return Last.LastAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> LastAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> LastAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Last.InvokeAsync(source, predicate, cancellationToken, false); return Last.LastAwaitAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> LastAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> LastAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -34,14 +34,14 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Last.InvokeAsync(source, predicate, cancellationToken, false); return Last.LastAwaitWithCancellationAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> LastOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken = default) public static UniTask<TSource> LastOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Last.InvokeAsync(source, cancellationToken, true); return Last.LastAsync(source, cancellationToken, true);
} }
public static UniTask<TSource> LastOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> LastOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -49,7 +49,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Last.InvokeAsync(source, predicate, cancellationToken, true); return Last.LastAsync(source, predicate, cancellationToken, true);
} }
public static UniTask<TSource> LastOrDefaultAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> LastOrDefaultAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -57,7 +57,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Last.InvokeAsync(source, predicate, cancellationToken, true); return Last.LastAwaitAsync(source, predicate, cancellationToken, true);
} }
public static UniTask<TSource> LastOrDefaultAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> LastOrDefaultAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -65,13 +65,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return Last.InvokeAsync(source, predicate, cancellationToken, true); return Last.LastAwaitWithCancellationAsync(source, predicate, cancellationToken, true);
} }
} }
internal static class Last internal static class Last
{ {
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> LastAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -108,7 +108,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> LastAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -151,7 +151,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> LastAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -194,7 +194,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> LastAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return LongCount.InvokeAsync(source, cancellationToken); return LongCount.LongCountAsync(source, cancellationToken);
} }
public static UniTask<long> LongCountAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<long> LongCountAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return LongCount.InvokeAsync(source, predicate, cancellationToken); return LongCount.LongCountAsync(source, predicate, cancellationToken);
} }
public static UniTask<long> LongCountAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<long> LongCountAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return LongCount.InvokeAsync(source, predicate, cancellationToken); return LongCount.LongCountAwaitAsync(source, predicate, cancellationToken);
} }
public static UniTask<long> LongCountAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<long> LongCountAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -34,13 +34,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return LongCount.InvokeAsync(source, predicate, cancellationToken); return LongCount.LongCountAwaitWithCancellationAsync(source, predicate, cancellationToken);
} }
} }
internal static class LongCount internal static class LongCount
{ {
internal static async UniTask<long> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) internal static async UniTask<long> LongCountAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
@ -63,7 +63,7 @@ namespace Cysharp.Threading.Tasks.Linq
return count; return count;
} }
internal static async UniTask<long> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken) internal static async UniTask<long> LongCountAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
@ -89,7 +89,7 @@ namespace Cysharp.Threading.Tasks.Linq
return count; return count;
} }
internal static async UniTask<long> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<long> LongCountAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;
@ -115,7 +115,7 @@ namespace Cysharp.Threading.Tasks.Linq
return count; return count;
} }
internal static async UniTask<long> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken) internal static async UniTask<long> LongCountAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken)
{ {
long count = 0; long count = 0;

View File

@ -11,7 +11,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Max.InvokeAsync(source, cancellationToken); return Max.MaxAsync(source, cancellationToken);
} }
public static UniTask<TResult> MaxAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken = default) public static UniTask<TResult> MaxAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken = default)
@ -19,7 +19,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Max.InvokeAsync(source, selector, cancellationToken); return Max.MaxAsync(source, selector, cancellationToken);
} }
public static UniTask<TResult> MaxAwaitAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken = default) public static UniTask<TResult> MaxAwaitAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken = default)
@ -27,21 +27,21 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Max.InvokeAsync(source, selector, cancellationToken); return Max.MaxAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<TResult> MaxAwaitCancellationAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken = default) public static UniTask<TResult> MaxAwaitWithCancellationAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Max.InvokeAsync(source, selector, cancellationToken); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
} }
internal static partial class Max internal static partial class Max
{ {
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) public static async UniTask<TSource> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
TSource value = default; TSource value = default;
var comparer = Comparer<TSource>.Default; var comparer = Comparer<TSource>.Default;
@ -80,7 +80,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<TResult> InvokeAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken) public static async UniTask<TResult> MaxAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
{ {
TResult value = default; TResult value = default;
var comparer = Comparer<TResult>.Default; var comparer = Comparer<TResult>.Default;
@ -119,7 +119,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<TResult> InvokeAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken) public static async UniTask<TResult> MaxAwaitAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken)
{ {
TResult value = default; TResult value = default;
var comparer = Comparer<TResult>.Default; var comparer = Comparer<TResult>.Default;
@ -158,7 +158,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<TResult> InvokeAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken) public static async UniTask<TResult> MaxAwaitWithCancellationAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken)
{ {
TResult value = default; TResult value = default;
var comparer = Comparer<TResult>.Default; var comparer = Comparer<TResult>.Default;

View File

@ -11,7 +11,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Min.InvokeAsync(source, cancellationToken); return Min.MinAsync(source, cancellationToken);
} }
public static UniTask<TResult> MinAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken = default) public static UniTask<TResult> MinAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken = default)
@ -19,7 +19,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Min.InvokeAsync(source, selector, cancellationToken); return Min.MinAsync(source, selector, cancellationToken);
} }
public static UniTask<TResult> MinAwaitAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken = default) public static UniTask<TResult> MinAwaitAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken = default)
@ -27,21 +27,21 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Min.InvokeAsync(source, selector, cancellationToken); return Min.MinAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<TResult> MinAwaitCancellationAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken = default) public static UniTask<TResult> MinAwaitWithCancellationAsync<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Min.InvokeAsync(source, selector, cancellationToken); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
} }
internal static partial class Min internal static partial class Min
{ {
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) public static async UniTask<TSource> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
TSource value = default; TSource value = default;
var comparer = Comparer<TSource>.Default; var comparer = Comparer<TSource>.Default;
@ -80,7 +80,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<TResult> InvokeAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken) public static async UniTask<TResult> MinAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
{ {
TResult value = default; TResult value = default;
var comparer = Comparer<TResult>.Default; var comparer = Comparer<TResult>.Default;
@ -119,7 +119,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<TResult> InvokeAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken) public static async UniTask<TResult> MinAwaitAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken)
{ {
TResult value = default; TResult value = default;
var comparer = Comparer<TResult>.Default; var comparer = Comparer<TResult>.Default;
@ -158,7 +158,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<TResult> InvokeAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken) public static async UniTask<TResult> MinAwaitWithCancellationAsync<TSource, TResult>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken)
{ {
TResult value = default; TResult value = default;
var comparer = Comparer<TResult>.Default; var comparer = Comparer<TResult>.Default;

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return <#= minMax #>.InvokeAsync(source, cancellationToken); return <#= minMax #>.<#= minMax #>Async(source, cancellationToken);
} }
public static UniTask<<#= TypeName(t) #>> <#= minMax #>Async<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= TypeName(t) #>> <#= minMax #>Async<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken = default)
@ -46,7 +46,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return <#= minMax #>.InvokeAsync(source, selector, cancellationToken); return <#= minMax #>.<#= minMax #>Async(source, selector, cancellationToken);
} }
public static UniTask<<#= TypeName(t) #>> <#= minMax #>AwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= TypeName(t) #>> <#= minMax #>AwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default)
@ -54,15 +54,15 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return <#= minMax #>.InvokeAsync(source, selector, cancellationToken); return <#= minMax #>.<#= minMax #>AwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<<#= TypeName(t) #>> <#= minMax #>AwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= TypeName(t) #>> <#= minMax #>AwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return <#= minMax #>.InvokeAsync(source, selector, cancellationToken); return <#= minMax #>.<#= minMax #>AwaitWithCancellationAsync(source, selector, cancellationToken);
} }
<# } #> <# } #>
@ -71,7 +71,7 @@ namespace Cysharp.Threading.Tasks.Linq
internal static partial class <#= minMax #> internal static partial class <#= minMax #>
{ {
<# foreach(var t in types) { #> <# foreach(var t in types) { #>
public static async UniTask<<#= TypeName(t) #>> InvokeAsync(IUniTaskAsyncEnumerable<<#= TypeName(t) #>> source, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> <#= minMax #>Async(IUniTaskAsyncEnumerable<<#= TypeName(t) #>> source, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> value = default; <#= TypeName(t) #> value = default;
@ -117,7 +117,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<<#= TypeName(t) #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> <#= minMax #>Async<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> value = default; <#= TypeName(t) #> value = default;
@ -163,7 +163,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<<#= TypeName(t) #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> <#= minMax #>AwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> value = default; <#= TypeName(t) #> value = default;
@ -209,7 +209,7 @@ namespace Cysharp.Threading.Tasks.Linq
return value; return value;
} }
public static async UniTask<<#= TypeName(t) #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> <#= minMax #>AwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> value = default; <#= TypeName(t) #> value = default;

View File

@ -20,14 +20,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(cancellationToken); return new _Never(cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<T> class _Never : IUniTaskAsyncEnumerator<T>
{ {
CancellationToken cancellationToken; CancellationToken cancellationToken;
public Enumerator(CancellationToken cancellationToken) public _Never(CancellationToken cancellationToken)
{ {
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
} }

View File

@ -25,12 +25,12 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _OfType(source, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<object, TResult> class _OfType : AsyncEnumeratorBase<object, TResult>
{ {
public Enumerator(IUniTaskAsyncEnumerable<object> source, CancellationToken cancellationToken) public _OfType(IUniTaskAsyncEnumerable<object> source, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {

View File

@ -407,10 +407,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TElement> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TElement> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(this, cancellationToken); return new _OrderedAsyncEnumerator(this, cancellationToken);
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TElement> class _OrderedAsyncEnumerator : MoveNextSource, IUniTaskAsyncEnumerator<TElement>
{ {
protected readonly OrderedAsyncEnumerable<TElement> parent; protected readonly OrderedAsyncEnumerable<TElement> parent;
CancellationToken cancellationToken; CancellationToken cancellationToken;
@ -418,7 +418,7 @@ namespace Cysharp.Threading.Tasks.Linq
int[] map; int[] map;
int index; int index;
public Enumerator(OrderedAsyncEnumerable<TElement> parent, CancellationToken cancellationToken) public _OrderedAsyncEnumerator(OrderedAsyncEnumerable<TElement> parent, CancellationToken cancellationToken)
{ {
this.parent = parent; this.parent = parent;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;

View File

@ -31,17 +31,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<int> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<int> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(start, end, cancellationToken); return new _Range(start, end, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<int> class _Range : IUniTaskAsyncEnumerator<int>
{ {
readonly int start; readonly int start;
readonly int end; readonly int end;
int current; int current;
CancellationToken cancellationToken; CancellationToken cancellationToken;
public Enumerator(int start, int end, CancellationToken cancellationToken) public _Range(int start, int end, CancellationToken cancellationToken)
{ {
this.start = start; this.start = start;
this.end = end; this.end = end;

View File

@ -26,17 +26,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TElement> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TElement> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(element, count, cancellationToken); return new _Repeat(element, count, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<TElement> class _Repeat : IUniTaskAsyncEnumerator<TElement>
{ {
readonly TElement element; readonly TElement element;
readonly int count; readonly int count;
int remaining; int remaining;
CancellationToken cancellationToken; CancellationToken cancellationToken;
public Enumerator(TElement element, int count, CancellationToken cancellationToken) public _Repeat(TElement element, int count, CancellationToken cancellationToken)
{ {
this.element = element; this.element = element;
this.count = count; this.count = count;

View File

@ -22,17 +22,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TValue> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TValue> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(value, cancellationToken); return new _Return(value, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<TValue> class _Return : IUniTaskAsyncEnumerator<TValue>
{ {
readonly TValue value; readonly TValue value;
CancellationToken cancellationToken; CancellationToken cancellationToken;
bool called; bool called;
public Enumerator(TValue value, CancellationToken cancellationToken) public _Return(TValue value, CancellationToken cancellationToken)
{ {
this.value = value; this.value = value;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;

View File

@ -25,10 +25,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _Reverse(source, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _Reverse : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
CancellationToken cancellationToken; CancellationToken cancellationToken;
@ -36,7 +36,7 @@ namespace Cysharp.Threading.Tasks.Linq
TSource[] array; TSource[] array;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) public _Reverse(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;

View File

@ -35,7 +35,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(selector, nameof(selector)); Error.ThrowArgumentNullException(selector, nameof(selector));
return new Cysharp.Threading.Tasks.Linq.SelectAwaitInt<TSource, TResult>(source, selector); return new Cysharp.Threading.Tasks.Linq.SelectIntAwait<TSource, TResult>(source, selector);
} }
public static IUniTaskAsyncEnumerable<TResult> SelectAwaitWithCancellation<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector) public static IUniTaskAsyncEnumerable<TResult> SelectAwaitWithCancellation<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector)
@ -43,7 +43,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(selector, nameof(selector)); Error.ThrowArgumentNullException(selector, nameof(selector));
return new Cysharp.Threading.Tasks.Linq.SelectAwaitCancellation<TSource, TResult>(source, selector); return new Cysharp.Threading.Tasks.Linq.SelectAwaitWithCancellation<TSource, TResult>(source, selector);
} }
public static IUniTaskAsyncEnumerable<TResult> SelectAwaitWithCancellation<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask<TResult>> selector) public static IUniTaskAsyncEnumerable<TResult> SelectAwaitWithCancellation<TSource, TResult>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask<TResult>> selector)
@ -51,7 +51,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(selector, nameof(selector)); Error.ThrowArgumentNullException(selector, nameof(selector));
return new Cysharp.Threading.Tasks.Linq.SelectAwaitIntCancellation<TSource, TResult>(source, selector); return new Cysharp.Threading.Tasks.Linq.SelectIntAwaitWithCancellation<TSource, TResult>(source, selector);
} }
} }
@ -68,14 +68,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector, cancellationToken); return new _Select(source, selector, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorBase<TSource, TResult> sealed class _Select : AsyncEnumeratorBase<TSource, TResult>
{ {
readonly Func<TSource, TResult> selector; readonly Func<TSource, TResult> selector;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken) public _Select(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TResult> selector, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.selector = selector; this.selector = selector;
@ -111,15 +111,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector, cancellationToken); return new _SelectInt(source, selector, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorBase<TSource, TResult> sealed class _SelectInt : AsyncEnumeratorBase<TSource, TResult>
{ {
readonly Func<TSource, int, TResult> selector; readonly Func<TSource, int, TResult> selector;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, TResult> selector, CancellationToken cancellationToken) public _SelectInt(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, TResult> selector, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.selector = selector; this.selector = selector;
@ -155,14 +155,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector, cancellationToken); return new _SelectAwait(source, selector, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult> sealed class _SelectAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult>
{ {
readonly Func<TSource, UniTask<TResult>> selector; readonly Func<TSource, UniTask<TResult>> selector;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken) public _SelectAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TResult>> selector, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.selector = selector; this.selector = selector;
@ -182,12 +182,12 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class SelectAwaitInt<TSource, TResult> : IUniTaskAsyncEnumerable<TResult> internal sealed class SelectIntAwait<TSource, TResult> : IUniTaskAsyncEnumerable<TResult>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, int, UniTask<TResult>> selector; readonly Func<TSource, int, UniTask<TResult>> selector;
public SelectAwaitInt(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<TResult>> selector) public SelectIntAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<TResult>> selector)
{ {
this.source = source; this.source = source;
this.selector = selector; this.selector = selector;
@ -195,15 +195,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector, cancellationToken); return new _SelectIntAwait(source, selector, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult> sealed class _SelectIntAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult>
{ {
readonly Func<TSource, int, UniTask<TResult>> selector; readonly Func<TSource, int, UniTask<TResult>> selector;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<TResult>> selector, CancellationToken cancellationToken) public _SelectIntAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<TResult>> selector, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.selector = selector; this.selector = selector;
@ -223,12 +223,12 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class SelectAwaitCancellation<TSource, TResult> : IUniTaskAsyncEnumerable<TResult> internal sealed class SelectAwaitWithCancellation<TSource, TResult> : IUniTaskAsyncEnumerable<TResult>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, CancellationToken, UniTask<TResult>> selector; readonly Func<TSource, CancellationToken, UniTask<TResult>> selector;
public SelectAwaitCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector) public SelectAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector)
{ {
this.source = source; this.source = source;
this.selector = selector; this.selector = selector;
@ -236,14 +236,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector, cancellationToken); return new _SelectAwaitWithCancellation(source, selector, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult> sealed class _SelectAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult>
{ {
readonly Func<TSource, CancellationToken, UniTask<TResult>> selector; readonly Func<TSource, CancellationToken, UniTask<TResult>> selector;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken) public _SelectAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.selector = selector; this.selector = selector;
@ -263,12 +263,12 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class SelectAwaitIntCancellation<TSource, TResult> : IUniTaskAsyncEnumerable<TResult> internal sealed class SelectIntAwaitWithCancellation<TSource, TResult> : IUniTaskAsyncEnumerable<TResult>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, int, CancellationToken, UniTask<TResult>> selector; readonly Func<TSource, int, CancellationToken, UniTask<TResult>> selector;
public SelectAwaitIntCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<TResult>> selector) public SelectIntAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<TResult>> selector)
{ {
this.source = source; this.source = source;
this.selector = selector; this.selector = selector;
@ -276,15 +276,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector, cancellationToken); return new _SelectIntAwaitWithCancellation(source, selector, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult> sealed class _SelectIntAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TResult, TResult>
{ {
readonly Func<TSource, int, CancellationToken, UniTask<TResult>> selector; readonly Func<TSource, int, CancellationToken, UniTask<TResult>> selector;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken) public _SelectIntAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<TResult>> selector, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.selector = selector; this.selector = selector;

View File

@ -129,10 +129,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector1, selector2, resultSelector, cancellationToken); return new _SelectMany(source, selector1, selector2, resultSelector, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _SelectMany : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> sourceMoveNextCoreDelegate = SourceMoveNextCore; static readonly Action<object> sourceMoveNextCoreDelegate = SourceMoveNextCore;
static readonly Action<object> selectedSourceMoveNextCoreDelegate = SeletedSourceMoveNextCore; static readonly Action<object> selectedSourceMoveNextCoreDelegate = SeletedSourceMoveNextCore;
@ -153,7 +153,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<bool>.Awaiter selectedAwaiter; UniTask<bool>.Awaiter selectedAwaiter;
UniTask.Awaiter selectedDisposeAsyncAwaiter; UniTask.Awaiter selectedDisposeAsyncAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, IUniTaskAsyncEnumerable<TCollection>> selector1, Func<TSource, int, IUniTaskAsyncEnumerable<TCollection>> selector2, Func<TSource, TCollection, TResult> resultSelector, CancellationToken cancellationToken) public _SelectMany(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, IUniTaskAsyncEnumerable<TCollection>> selector1, Func<TSource, int, IUniTaskAsyncEnumerable<TCollection>> selector2, Func<TSource, TCollection, TResult> resultSelector, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.selector1 = selector1; this.selector1 = selector1;
@ -232,7 +232,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SourceMoveNextCore(object state) static void SourceMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectMany)state;
if (self.TryGetResult(self.sourceAwaiter, out var result)) if (self.TryGetResult(self.sourceAwaiter, out var result))
{ {
@ -267,7 +267,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SeletedSourceMoveNextCore(object state) static void SeletedSourceMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectMany)state;
if (self.TryGetResult(self.selectedAwaiter, out var result)) if (self.TryGetResult(self.selectedAwaiter, out var result))
{ {
@ -311,7 +311,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SelectedEnumeratorDisposeAsyncCore(object state) static void SelectedEnumeratorDisposeAsyncCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectMany)state;
if (self.TryGetResult(self.selectedDisposeAsyncAwaiter)) if (self.TryGetResult(self.selectedDisposeAsyncAwaiter))
{ {
@ -361,10 +361,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector1, selector2, resultSelector, cancellationToken); return new _SelectManyAwait(source, selector1, selector2, resultSelector, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _SelectManyAwait : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> sourceMoveNextCoreDelegate = SourceMoveNextCore; static readonly Action<object> sourceMoveNextCoreDelegate = SourceMoveNextCore;
static readonly Action<object> selectedSourceMoveNextCoreDelegate = SeletedSourceMoveNextCore; static readonly Action<object> selectedSourceMoveNextCoreDelegate = SeletedSourceMoveNextCore;
@ -391,7 +391,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<IUniTaskAsyncEnumerable<TCollection>>.Awaiter collectionSelectorAwaiter; UniTask<IUniTaskAsyncEnumerable<TCollection>>.Awaiter collectionSelectorAwaiter;
UniTask<TResult>.Awaiter resultSelectorAwaiter; UniTask<TResult>.Awaiter resultSelectorAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector1, Func<TSource, int, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector2, Func<TSource, TCollection, UniTask<TResult>> resultSelector, CancellationToken cancellationToken) public _SelectManyAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector1, Func<TSource, int, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector2, Func<TSource, TCollection, UniTask<TResult>> resultSelector, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.selector1 = selector1; this.selector1 = selector1;
@ -470,7 +470,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SourceMoveNextCore(object state) static void SourceMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwait)state;
if (self.TryGetResult(self.sourceAwaiter, out var result)) if (self.TryGetResult(self.sourceAwaiter, out var result))
{ {
@ -513,7 +513,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SeletedSourceMoveNextCore(object state) static void SeletedSourceMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwait)state;
if (self.TryGetResult(self.selectedAwaiter, out var result)) if (self.TryGetResult(self.selectedAwaiter, out var result))
{ {
@ -563,7 +563,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SelectedEnumeratorDisposeAsyncCore(object state) static void SelectedEnumeratorDisposeAsyncCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwait)state;
if (self.TryGetResult(self.selectedDisposeAsyncAwaiter)) if (self.TryGetResult(self.selectedDisposeAsyncAwaiter))
{ {
@ -576,7 +576,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SelectorAwaitCore(object state) static void SelectorAwaitCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwait)state;
if (self.TryGetResult(self.collectionSelectorAwaiter, out var result)) if (self.TryGetResult(self.collectionSelectorAwaiter, out var result))
{ {
@ -587,7 +587,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectorAwaitCore(object state) static void ResultSelectorAwaitCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwait)state;
if (self.TryGetResult(self.resultSelectorAwaiter, out var result)) if (self.TryGetResult(self.resultSelectorAwaiter, out var result))
{ {
@ -635,10 +635,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, selector1, selector2, resultSelector, cancellationToken); return new _SelectManyAwaitWithCancellation(source, selector1, selector2, resultSelector, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _SelectManyAwaitWithCancellation : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> sourceMoveNextCoreDelegate = SourceMoveNextCore; static readonly Action<object> sourceMoveNextCoreDelegate = SourceMoveNextCore;
static readonly Action<object> selectedSourceMoveNextCoreDelegate = SeletedSourceMoveNextCore; static readonly Action<object> selectedSourceMoveNextCoreDelegate = SeletedSourceMoveNextCore;
@ -665,7 +665,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<IUniTaskAsyncEnumerable<TCollection>>.Awaiter collectionSelectorAwaiter; UniTask<IUniTaskAsyncEnumerable<TCollection>>.Awaiter collectionSelectorAwaiter;
UniTask<TResult>.Awaiter resultSelectorAwaiter; UniTask<TResult>.Awaiter resultSelectorAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector1, Func<TSource, int, CancellationToken, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector2, Func<TSource, TCollection, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken) public _SelectManyAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector1, Func<TSource, int, CancellationToken, UniTask<IUniTaskAsyncEnumerable<TCollection>>> selector2, Func<TSource, TCollection, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.selector1 = selector1; this.selector1 = selector1;
@ -744,7 +744,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SourceMoveNextCore(object state) static void SourceMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwaitWithCancellation)state;
if (self.TryGetResult(self.sourceAwaiter, out var result)) if (self.TryGetResult(self.sourceAwaiter, out var result))
{ {
@ -787,7 +787,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SeletedSourceMoveNextCore(object state) static void SeletedSourceMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwaitWithCancellation)state;
if (self.TryGetResult(self.selectedAwaiter, out var result)) if (self.TryGetResult(self.selectedAwaiter, out var result))
{ {
@ -837,7 +837,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SelectedEnumeratorDisposeAsyncCore(object state) static void SelectedEnumeratorDisposeAsyncCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwaitWithCancellation)state;
if (self.TryGetResult(self.selectedDisposeAsyncAwaiter)) if (self.TryGetResult(self.selectedDisposeAsyncAwaiter))
{ {
@ -850,7 +850,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SelectorAwaitCore(object state) static void SelectorAwaitCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwaitWithCancellation)state;
if (self.TryGetResult(self.collectionSelectorAwaiter, out var result)) if (self.TryGetResult(self.collectionSelectorAwaiter, out var result))
{ {
@ -861,7 +861,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultSelectorAwaitCore(object state) static void ResultSelectorAwaitCore(object state)
{ {
var self = (Enumerator)state; var self = (_SelectManyAwaitWithCancellation)state;
if (self.TryGetResult(self.resultSelectorAwaiter, out var result)) if (self.TryGetResult(self.resultSelectorAwaiter, out var result))
{ {

View File

@ -18,13 +18,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(second, nameof(second)); Error.ThrowArgumentNullException(second, nameof(second));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return SequenceEqual.InvokeAsync(first, second, comparer, cancellationToken); return SequenceEqual.SequenceEqualAsync(first, second, comparer, cancellationToken);
} }
} }
internal static class SequenceEqual internal static class SequenceEqual
{ {
internal static async UniTask<bool> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) internal static async UniTask<bool> SequenceEqualAsync<TSource>(IUniTaskAsyncEnumerable<TSource> first, IUniTaskAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
{ {
var e1 = first.GetAsyncEnumerator(cancellationToken); var e1 = first.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return SingleOperator.InvokeAsync(source, cancellationToken, false); return SingleOperator.SingleAsync(source, cancellationToken, false);
} }
public static UniTask<TSource> SingleAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return SingleOperator.InvokeAsync(source, predicate, cancellationToken, false); return SingleOperator.SingleAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> SingleAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return SingleOperator.InvokeAsync(source, predicate, cancellationToken, false); return SingleOperator.SingleAwaitAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> SingleAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -34,14 +34,14 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return SingleOperator.InvokeAsync(source, predicate, cancellationToken, false); return SingleOperator.SingleAwaitWithCancellationAsync(source, predicate, cancellationToken, false);
} }
public static UniTask<TSource> SingleOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return SingleOperator.InvokeAsync(source, cancellationToken, true); return SingleOperator.SingleAsync(source, cancellationToken, true);
} }
public static UniTask<TSource> SingleOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleOrDefaultAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken = default)
@ -49,7 +49,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return SingleOperator.InvokeAsync(source, predicate, cancellationToken, true); return SingleOperator.SingleAsync(source, predicate, cancellationToken, true);
} }
public static UniTask<TSource> SingleOrDefaultAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleOrDefaultAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -57,7 +57,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return SingleOperator.InvokeAsync(source, predicate, cancellationToken, true); return SingleOperator.SingleAwaitAsync(source, predicate, cancellationToken, true);
} }
public static UniTask<TSource> SingleOrDefaultAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default) public static UniTask<TSource> SingleOrDefaultAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken = default)
@ -65,13 +65,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return SingleOperator.InvokeAsync(source, predicate, cancellationToken, true); return SingleOperator.SingleAwaitWithCancellationAsync(source, predicate, cancellationToken, true);
} }
} }
internal static class SingleOperator internal static class SingleOperator
{ {
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> SingleAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -107,7 +107,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> SingleAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Boolean> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -147,7 +147,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> SingleAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try
@ -187,7 +187,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
public static async UniTask<TSource> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty) public static async UniTask<TSource> SingleAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate, CancellationToken cancellationToken, bool defaultIfEmpty)
{ {
var e = source.GetAsyncEnumerator(cancellationToken); var e = source.GetAsyncEnumerator(cancellationToken);
try try

View File

@ -27,16 +27,16 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, count, cancellationToken); return new _Skip(source, count, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorBase<TSource, TSource> sealed class _Skip : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly int count; readonly int count;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken) public _Skip(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.count = count; this.count = count;

View File

@ -34,10 +34,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, count, cancellationToken); return new _SkipLast(source, count, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _SkipLast : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -51,7 +51,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool continueNext; bool continueNext;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken) public _SkipLast(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.count = count; this.count = count;
@ -106,7 +106,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_SkipLast)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -68,14 +68,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _SkipWhile(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _SkipWhile : AsyncEnumeratorBase<TSource, TSource>
{ {
Func<TSource, bool> predicate; Func<TSource, bool> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken) public _SkipWhile(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -119,15 +119,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _SkipWhileInt(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _SkipWhileInt : AsyncEnumeratorBase<TSource, TSource>
{ {
Func<TSource, int, bool> predicate; Func<TSource, int, bool> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate, CancellationToken cancellationToken) public _SkipWhileInt(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -171,14 +171,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _SkipWhileAwait(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _SkipWhileAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
Func<TSource, UniTask<bool>> predicate; Func<TSource, UniTask<bool>> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<bool>> predicate, CancellationToken cancellationToken) public _SkipWhileAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -226,15 +226,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _SkipWhileIntAwait(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _SkipWhileIntAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
Func<TSource, int, UniTask<bool>> predicate; Func<TSource, int, UniTask<bool>> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate, CancellationToken cancellationToken) public _SkipWhileIntAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -281,14 +281,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _SkipWhileAwaitWithCancellation(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _SkipWhileAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
Func<TSource, CancellationToken, UniTask<bool>> predicate; Func<TSource, CancellationToken, UniTask<bool>> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken) public _SkipWhileAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -335,15 +335,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _SkipWhileIntAwaitWithCancellation(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _SkipWhileIntAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
Func<TSource, int, CancellationToken, UniTask<bool>> predicate; Func<TSource, int, CancellationToken, UniTask<bool>> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken) public _SkipWhileIntAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Int32> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken = default) public static UniTask<Int32> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken = default)
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Int32> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken = default) public static UniTask<Int32> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
@ -26,22 +26,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Int32> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken = default) public static UniTask<Int32> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Int64> SumAsync(this IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken = default) public static UniTask<Int64> SumAsync(this IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Int64> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken = default) public static UniTask<Int64> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken = default)
@ -49,7 +49,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Int64> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken = default) public static UniTask<Int64> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
@ -57,22 +57,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Int64> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken = default) public static UniTask<Int64> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Single> SumAsync(this IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken = default) public static UniTask<Single> SumAsync(this IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Single> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken = default) public static UniTask<Single> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken = default)
@ -80,7 +80,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Single> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken = default) public static UniTask<Single> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken = default)
@ -88,22 +88,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Single> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken = default) public static UniTask<Single> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Double> SumAsync(this IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken = default) public static UniTask<Double> SumAsync(this IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Double> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken = default) public static UniTask<Double> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken = default)
@ -111,7 +111,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Double> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken = default) public static UniTask<Double> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken = default)
@ -119,22 +119,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Double> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken = default) public static UniTask<Double> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Decimal> SumAsync(this IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken = default) public static UniTask<Decimal> SumAsync(this IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Decimal> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken = default) public static UniTask<Decimal> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken = default)
@ -142,7 +142,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Decimal> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken = default) public static UniTask<Decimal> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
@ -150,22 +150,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Decimal> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken = default) public static UniTask<Decimal> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Int32?> SumAsync(this IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken = default) public static UniTask<Int32?> SumAsync(this IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Int32?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken = default) public static UniTask<Int32?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken = default)
@ -173,7 +173,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Int32?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken = default) public static UniTask<Int32?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
@ -181,22 +181,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Int32?> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken = default) public static UniTask<Int32?> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Int64?> SumAsync(this IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken = default) public static UniTask<Int64?> SumAsync(this IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Int64?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken = default) public static UniTask<Int64?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken = default)
@ -204,7 +204,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Int64?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken = default) public static UniTask<Int64?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
@ -212,22 +212,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Int64?> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken = default) public static UniTask<Int64?> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Single?> SumAsync(this IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken = default) public static UniTask<Single?> SumAsync(this IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Single?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken = default) public static UniTask<Single?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken = default)
@ -235,7 +235,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Single?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken = default) public static UniTask<Single?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
@ -243,22 +243,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Single?> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken = default) public static UniTask<Single?> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Double?> SumAsync(this IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken = default) public static UniTask<Double?> SumAsync(this IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Double?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken = default) public static UniTask<Double?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken = default)
@ -266,7 +266,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Double?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken = default) public static UniTask<Double?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
@ -274,22 +274,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Double?> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken = default) public static UniTask<Double?> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
public static UniTask<Decimal?> SumAsync(this IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken = default) public static UniTask<Decimal?> SumAsync(this IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<Decimal?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken = default) public static UniTask<Decimal?> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken = default)
@ -297,7 +297,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<Decimal?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default) public static UniTask<Decimal?> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
@ -305,22 +305,22 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<Decimal?> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default) public static UniTask<Decimal?> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
} }
internal static class Sum internal static class Sum
{ {
public static async UniTask<Int32> InvokeAsync(IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken) public static async UniTask<Int32> SumAsync(IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken)
{ {
Int32 sum = default; Int32 sum = default;
@ -343,7 +343,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken) public static async UniTask<Int32> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken)
{ {
Int32 sum = default; Int32 sum = default;
@ -366,7 +366,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken) public static async UniTask<Int32> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken)
{ {
Int32 sum = default; Int32 sum = default;
@ -389,7 +389,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken) public static async UniTask<Int32> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken)
{ {
Int32 sum = default; Int32 sum = default;
@ -412,7 +412,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64> InvokeAsync(IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken) public static async UniTask<Int64> SumAsync(IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken)
{ {
Int64 sum = default; Int64 sum = default;
@ -435,7 +435,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken) public static async UniTask<Int64> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken)
{ {
Int64 sum = default; Int64 sum = default;
@ -458,7 +458,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken) public static async UniTask<Int64> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken)
{ {
Int64 sum = default; Int64 sum = default;
@ -481,7 +481,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken) public static async UniTask<Int64> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken)
{ {
Int64 sum = default; Int64 sum = default;
@ -504,7 +504,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single> InvokeAsync(IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken) public static async UniTask<Single> SumAsync(IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken)
{ {
Single sum = default; Single sum = default;
@ -527,7 +527,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken) public static async UniTask<Single> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken)
{ {
Single sum = default; Single sum = default;
@ -550,7 +550,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken) public static async UniTask<Single> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken)
{ {
Single sum = default; Single sum = default;
@ -573,7 +573,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken) public static async UniTask<Single> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken)
{ {
Single sum = default; Single sum = default;
@ -596,7 +596,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double> InvokeAsync(IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken) public static async UniTask<Double> SumAsync(IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken)
{ {
Double sum = default; Double sum = default;
@ -619,7 +619,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken) public static async UniTask<Double> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken)
{ {
Double sum = default; Double sum = default;
@ -642,7 +642,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken) public static async UniTask<Double> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken)
{ {
Double sum = default; Double sum = default;
@ -665,7 +665,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken) public static async UniTask<Double> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken)
{ {
Double sum = default; Double sum = default;
@ -688,7 +688,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal> InvokeAsync(IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken) public static async UniTask<Decimal> SumAsync(IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken)
{ {
Decimal sum = default; Decimal sum = default;
@ -711,7 +711,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken) public static async UniTask<Decimal> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken)
{ {
Decimal sum = default; Decimal sum = default;
@ -734,7 +734,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken) public static async UniTask<Decimal> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken)
{ {
Decimal sum = default; Decimal sum = default;
@ -757,7 +757,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken) public static async UniTask<Decimal> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken)
{ {
Decimal sum = default; Decimal sum = default;
@ -780,7 +780,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32?> InvokeAsync(IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken) public static async UniTask<Int32?> SumAsync(IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken)
{ {
Int32? sum = default; Int32? sum = default;
@ -803,7 +803,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken) public static async UniTask<Int32?> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken)
{ {
Int32? sum = default; Int32? sum = default;
@ -826,7 +826,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken) public static async UniTask<Int32?> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken)
{ {
Int32? sum = default; Int32? sum = default;
@ -849,7 +849,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int32?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken) public static async UniTask<Int32?> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken)
{ {
Int32? sum = default; Int32? sum = default;
@ -872,7 +872,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64?> InvokeAsync(IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken) public static async UniTask<Int64?> SumAsync(IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken)
{ {
Int64? sum = default; Int64? sum = default;
@ -895,7 +895,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken) public static async UniTask<Int64?> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken)
{ {
Int64? sum = default; Int64? sum = default;
@ -918,7 +918,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken) public static async UniTask<Int64?> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken)
{ {
Int64? sum = default; Int64? sum = default;
@ -941,7 +941,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Int64?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken) public static async UniTask<Int64?> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken)
{ {
Int64? sum = default; Int64? sum = default;
@ -964,7 +964,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single?> InvokeAsync(IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken) public static async UniTask<Single?> SumAsync(IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken)
{ {
Single? sum = default; Single? sum = default;
@ -987,7 +987,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken) public static async UniTask<Single?> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken)
{ {
Single? sum = default; Single? sum = default;
@ -1010,7 +1010,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken) public static async UniTask<Single?> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken)
{ {
Single? sum = default; Single? sum = default;
@ -1033,7 +1033,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Single?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken) public static async UniTask<Single?> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken)
{ {
Single? sum = default; Single? sum = default;
@ -1056,7 +1056,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double?> InvokeAsync(IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken) public static async UniTask<Double?> SumAsync(IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken)
{ {
Double? sum = default; Double? sum = default;
@ -1079,7 +1079,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken) public static async UniTask<Double?> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken)
{ {
Double? sum = default; Double? sum = default;
@ -1102,7 +1102,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken) public static async UniTask<Double?> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken)
{ {
Double? sum = default; Double? sum = default;
@ -1125,7 +1125,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Double?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken) public static async UniTask<Double?> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken)
{ {
Double? sum = default; Double? sum = default;
@ -1148,7 +1148,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal?> InvokeAsync(IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken) public static async UniTask<Decimal?> SumAsync(IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken)
{ {
Decimal? sum = default; Decimal? sum = default;
@ -1171,7 +1171,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken) public static async UniTask<Decimal?> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken)
{ {
Decimal? sum = default; Decimal? sum = default;
@ -1194,7 +1194,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken) public static async UniTask<Decimal?> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
{ {
Decimal? sum = default; Decimal? sum = default;
@ -1217,7 +1217,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<Decimal?> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken) public static async UniTask<Decimal?> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
{ {
Decimal? sum = default; Decimal? sum = default;

View File

@ -37,7 +37,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Sum.InvokeAsync(source, cancellationToken); return Sum.SumAsync(source, cancellationToken);
} }
public static UniTask<<#= TypeName(t) #>> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= TypeName(t) #>> SumAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken = default)
@ -45,7 +45,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAsync(source, selector, cancellationToken);
} }
public static UniTask<<#= TypeName(t) #>> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= TypeName(t) #>> SumAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default)
@ -53,15 +53,15 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitAsync(source, selector, cancellationToken);
} }
public static UniTask<<#= TypeName(t) #>> SumAwaitCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default) public static UniTask<<#= TypeName(t) #>> SumAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken = default)
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(source, nameof(selector)); Error.ThrowArgumentNullException(source, nameof(selector));
return Sum.InvokeAsync(source, selector, cancellationToken); return Sum.SumAwaitWithCancellationAsync(source, selector, cancellationToken);
} }
<# } #> <# } #>
@ -70,7 +70,7 @@ namespace Cysharp.Threading.Tasks.Linq
internal static class Sum internal static class Sum
{ {
<# foreach(var t in types) { #> <# foreach(var t in types) { #>
public static async UniTask<<#= TypeName(t) #>> InvokeAsync(IUniTaskAsyncEnumerable<<#= TypeName(t) #>> source, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> SumAsync(IUniTaskAsyncEnumerable<<#= TypeName(t) #>> source, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> sum = default; <#= TypeName(t) #> sum = default;
@ -93,7 +93,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<<#= TypeName(t) #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> SumAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, <#= TypeName(t) #>> selector, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> sum = default; <#= TypeName(t) #> sum = default;
@ -116,7 +116,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<<#= TypeName(t) #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> SumAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> sum = default; <#= TypeName(t) #> sum = default;
@ -139,7 +139,7 @@ namespace Cysharp.Threading.Tasks.Linq
return sum; return sum;
} }
public static async UniTask<<#= TypeName(t) #>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken) public static async UniTask<<#= TypeName(t) #>> SumAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<<#= TypeName(t) #>>> selector, CancellationToken cancellationToken)
{ {
<#= TypeName(t) #> sum = default; <#= TypeName(t) #> sum = default;

View File

@ -27,16 +27,16 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, count, cancellationToken); return new _Take(source, count, cancellationToken);
} }
sealed class Enumerator : AsyncEnumeratorBase<TSource, TSource> sealed class _Take : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly int count; readonly int count;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken) public _Take(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.count = count; this.count = count;

View File

@ -34,10 +34,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, count, cancellationToken); return new _TakeLast(source, count, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TSource> sealed class _TakeLast : MoveNextSource, IUniTaskAsyncEnumerator<TSource>
{ {
static readonly Action<object> MoveNextCoreDelegate = MoveNextCore; static readonly Action<object> MoveNextCoreDelegate = MoveNextCore;
@ -52,7 +52,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool iterateCompleted; bool iterateCompleted;
bool continueNext; bool continueNext;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken) public _TakeLast(IUniTaskAsyncEnumerable<TSource> source, int count, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.count = count; this.count = count;
@ -121,7 +121,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void MoveNextCore(object state) static void MoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_TakeLast)state;
if (self.TryGetResult(self.awaiter, out var result)) if (self.TryGetResult(self.awaiter, out var result))
{ {

View File

@ -68,14 +68,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _TakeWhile(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _TakeWhile : AsyncEnumeratorBase<TSource, TSource>
{ {
Func<TSource, bool> predicate; Func<TSource, bool> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken) public _TakeWhile(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -113,15 +113,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _TakeWhileInt(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _TakeWhileInt : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly Func<TSource, int, bool> predicate; readonly Func<TSource, int, bool> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate, CancellationToken cancellationToken) public _TakeWhileInt(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -159,14 +159,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _TakeWhileAwait(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _TakeWhileAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
Func<TSource, UniTask<bool>> predicate; Func<TSource, UniTask<bool>> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<bool>> predicate, CancellationToken cancellationToken) public _TakeWhileAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.predicate = predicate; this.predicate = predicate;
@ -207,15 +207,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _TakeWhileIntAwait(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _TakeWhileIntAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
readonly Func<TSource, int, UniTask<bool>> predicate; readonly Func<TSource, int, UniTask<bool>> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate, CancellationToken cancellationToken) public _TakeWhileIntAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.predicate = predicate; this.predicate = predicate;
@ -256,14 +256,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _TakeWhileAwaitWithCancellation(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _TakeWhileAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
Func<TSource, CancellationToken, UniTask<bool>> predicate; Func<TSource, CancellationToken, UniTask<bool>> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken) public _TakeWhileAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.predicate = predicate; this.predicate = predicate;
@ -304,15 +304,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _TakeWhileIntAwaitWithCancellation(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _TakeWhileIntAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
readonly Func<TSource, int, CancellationToken, UniTask<bool>> predicate; readonly Func<TSource, int, CancellationToken, UniTask<bool>> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken) public _TakeWhileIntAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
this.predicate = predicate; this.predicate = predicate;

View File

@ -23,15 +23,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TValue> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TValue> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(exception, cancellationToken); return new _Throw(exception, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<TValue> class _Throw : IUniTaskAsyncEnumerator<TValue>
{ {
readonly Exception exception; readonly Exception exception;
CancellationToken cancellationToken; CancellationToken cancellationToken;
public Enumerator(Exception exception, CancellationToken cancellationToken) public _Throw(Exception exception, CancellationToken cancellationToken)
{ {
this.exception = exception; this.exception = exception;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;

View File

@ -11,13 +11,13 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Cysharp.Threading.Tasks.Linq.ToArray.InvokeAsync(source, cancellationToken); return Cysharp.Threading.Tasks.Linq.ToArray.ToArrayAsync(source, cancellationToken);
} }
} }
internal static class ToArray internal static class ToArray
{ {
internal static async UniTask<TSource[]> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) internal static async UniTask<TSource[]> ToArrayAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);

View File

@ -12,7 +12,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
return ToDictionary.InvokeAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken); return ToDictionary.ToDictionaryAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -21,7 +21,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToDictionary.InvokeAsync(source, keySelector, comparer, cancellationToken); return ToDictionary.ToDictionaryAsync(source, keySelector, comparer, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken = default)
@ -30,7 +30,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
return ToDictionary.InvokeAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken); return ToDictionary.ToDictionaryAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -40,7 +40,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToDictionary.InvokeAsync(source, keySelector, elementSelector, comparer, cancellationToken); return ToDictionary.ToDictionaryAsync(source, keySelector, elementSelector, comparer, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default)
@ -48,7 +48,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
return ToDictionary.InvokeAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken); return ToDictionary.ToDictionaryAwaitAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -57,7 +57,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToDictionary.InvokeAsync(source, keySelector, comparer, cancellationToken); return ToDictionary.ToDictionaryAwaitAsync(source, keySelector, comparer, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default)
@ -66,7 +66,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
return ToDictionary.InvokeAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken); return ToDictionary.ToDictionaryAwaitAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -76,7 +76,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToDictionary.InvokeAsync(source, keySelector, elementSelector, comparer, cancellationToken); return ToDictionary.ToDictionaryAwaitAsync(source, keySelector, elementSelector, comparer, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default)
@ -84,7 +84,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
return ToDictionary.InvokeAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken); return ToDictionary.ToDictionaryAwaitWithCancellationAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -93,7 +93,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToDictionary.InvokeAsync(source, keySelector, comparer, cancellationToken); return ToDictionary.ToDictionaryAwaitWithCancellationAsync(source, keySelector, comparer, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default)
@ -102,7 +102,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
return ToDictionary.InvokeAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken); return ToDictionary.ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -112,13 +112,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToDictionary.InvokeAsync(source, keySelector, elementSelector, comparer, cancellationToken); return ToDictionary.ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer, cancellationToken);
} }
} }
internal static class ToDictionary internal static class ToDictionary
{ {
internal static async UniTask<Dictionary<TKey, TSource>> InvokeAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var dict = new Dictionary<TKey, TSource>(comparer); var dict = new Dictionary<TKey, TSource>(comparer);
@ -143,7 +143,7 @@ namespace Cysharp.Threading.Tasks.Linq
return dict; return dict;
} }
internal static async UniTask<Dictionary<TKey, TElement>> InvokeAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var dict = new Dictionary<TKey, TElement>(comparer); var dict = new Dictionary<TKey, TElement>(comparer);
@ -171,7 +171,7 @@ namespace Cysharp.Threading.Tasks.Linq
// with await // with await
internal static async UniTask<Dictionary<TKey, TSource>> InvokeAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var dict = new Dictionary<TKey, TSource>(comparer); var dict = new Dictionary<TKey, TSource>(comparer);
@ -196,7 +196,7 @@ namespace Cysharp.Threading.Tasks.Linq
return dict; return dict;
} }
internal static async UniTask<Dictionary<TKey, TElement>> InvokeAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var dict = new Dictionary<TKey, TElement>(comparer); var dict = new Dictionary<TKey, TElement>(comparer);
@ -224,7 +224,7 @@ namespace Cysharp.Threading.Tasks.Linq
// with cancellation // with cancellation
internal static async UniTask<Dictionary<TKey, TSource>> InvokeAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<Dictionary<TKey, TSource>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var dict = new Dictionary<TKey, TSource>(comparer); var dict = new Dictionary<TKey, TSource>(comparer);
@ -249,7 +249,7 @@ namespace Cysharp.Threading.Tasks.Linq
return dict; return dict;
} }
internal static async UniTask<Dictionary<TKey, TElement>> InvokeAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<Dictionary<TKey, TElement>> ToDictionaryAwaitWithCancellationAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var dict = new Dictionary<TKey, TElement>(comparer); var dict = new Dictionary<TKey, TElement>(comparer);

View File

@ -10,7 +10,7 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Cysharp.Threading.Tasks.Linq.ToHashSet.InvokeAsync(source, EqualityComparer<TSource>.Default, cancellationToken); return Cysharp.Threading.Tasks.Linq.ToHashSet.ToHashSetAsync(source, EqualityComparer<TSource>.Default, cancellationToken);
} }
public static UniTask<HashSet<TSource>> ToHashSetAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken = default) public static UniTask<HashSet<TSource>> ToHashSetAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken = default)
@ -18,13 +18,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return Cysharp.Threading.Tasks.Linq.ToHashSet.InvokeAsync(source, comparer, cancellationToken); return Cysharp.Threading.Tasks.Linq.ToHashSet.ToHashSetAsync(source, comparer, cancellationToken);
} }
} }
internal static class ToHashSet internal static class ToHashSet
{ {
internal static async UniTask<HashSet<TSource>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken) internal static async UniTask<HashSet<TSource>> ToHashSetAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
{ {
var set = new HashSet<TSource>(comparer); var set = new HashSet<TSource>(comparer);

View File

@ -10,13 +10,13 @@ namespace Cysharp.Threading.Tasks.Linq
{ {
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
return Cysharp.Threading.Tasks.Linq.ToList.InvokeAsync(source, cancellationToken); return Cysharp.Threading.Tasks.Linq.ToList.ToListAsync(source, cancellationToken);
} }
} }
internal static class ToList internal static class ToList
{ {
internal static async UniTask<List<TSource>> InvokeAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken) internal static async UniTask<List<TSource>> ToListAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, CancellationToken cancellationToken)
{ {
var list = new List<TSource>(); var list = new List<TSource>();

View File

@ -14,7 +14,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
return ToLookup.InvokeAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken); return ToLookup.ToLookupAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<ILookup<TKey, TSource>> ToLookupAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TSource>> ToLookupAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -23,7 +23,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToLookup.InvokeAsync(source, keySelector, comparer, cancellationToken); return ToLookup.ToLookupAsync(source, keySelector, comparer, cancellationToken);
} }
public static UniTask<ILookup<TKey, TElement>> ToLookupAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TElement>> ToLookupAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken cancellationToken = default)
@ -32,7 +32,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
return ToLookup.InvokeAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken); return ToLookup.ToLookupAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<ILookup<TKey, TElement>> ToLookupAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TElement>> ToLookupAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -42,7 +42,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToLookup.InvokeAsync(source, keySelector, elementSelector, comparer, cancellationToken); return ToLookup.ToLookupAsync(source, keySelector, elementSelector, comparer, cancellationToken);
} }
public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default)
@ -50,7 +50,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
return ToLookup.InvokeAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken); return ToLookup.ToLookupAwaitAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -59,7 +59,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToLookup.InvokeAsync(source, keySelector, comparer, cancellationToken); return ToLookup.ToLookupAwaitAsync(source, keySelector, comparer, cancellationToken);
} }
public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default)
@ -68,7 +68,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
return ToLookup.InvokeAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken); return ToLookup.ToLookupAwaitAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -78,7 +78,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToLookup.InvokeAsync(source, keySelector, elementSelector, comparer, cancellationToken); return ToLookup.ToLookupAwaitAsync(source, keySelector, elementSelector, comparer, cancellationToken);
} }
public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, CancellationToken cancellationToken = default)
@ -86,7 +86,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
return ToLookup.InvokeAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken); return ToLookup.ToLookupAwaitWithCancellationAsync(source, keySelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TSource>> ToLookupAwaitWithCancellationAsync<TSource, TKey>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -95,7 +95,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToLookup.InvokeAsync(source, keySelector, comparer, cancellationToken); return ToLookup.ToLookupAwaitWithCancellationAsync(source, keySelector, comparer, cancellationToken);
} }
public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, CancellationToken cancellationToken = default)
@ -104,7 +104,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(keySelector, nameof(keySelector)); Error.ThrowArgumentNullException(keySelector, nameof(keySelector));
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
return ToLookup.InvokeAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken); return ToLookup.ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, EqualityComparer<TKey>.Default, cancellationToken);
} }
public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default) public static UniTask<ILookup<TKey, TElement>> ToLookupAwaitWithCancellationAsync<TSource, TKey, TElement>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken = default)
@ -114,13 +114,13 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector)); Error.ThrowArgumentNullException(elementSelector, nameof(elementSelector));
Error.ThrowArgumentNullException(comparer, nameof(comparer)); Error.ThrowArgumentNullException(comparer, nameof(comparer));
return ToLookup.InvokeAsync(source, keySelector, elementSelector, comparer, cancellationToken); return ToLookup.ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer, cancellationToken);
} }
} }
internal static class ToLookup internal static class ToLookup
{ {
internal static async UniTask<ILookup<TKey, TSource>> InvokeAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<ILookup<TKey, TSource>> ToLookupAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);
@ -155,7 +155,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<ILookup<TKey, TElement>> InvokeAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<ILookup<TKey, TElement>> ToLookupAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);
@ -194,7 +194,7 @@ namespace Cysharp.Threading.Tasks.Linq
// with await // with await
internal static async UniTask<ILookup<TKey, TSource>> InvokeAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<ILookup<TKey, TSource>> ToLookupAwaitAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);
@ -230,7 +230,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<ILookup<TKey, TElement>> InvokeAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<ILookup<TKey, TElement>> ToLookupAwaitAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<TKey>> keySelector, Func<TSource, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);
@ -268,7 +268,7 @@ namespace Cysharp.Threading.Tasks.Linq
// with cancellation // with cancellation
internal static async UniTask<ILookup<TKey, TSource>> InvokeAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<ILookup<TKey, TSource>> ToLookupAwaitWithCancellationAsync<TSource, TKey>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);
@ -304,7 +304,7 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal static async UniTask<ILookup<TKey, TElement>> InvokeAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken) internal static async UniTask<ILookup<TKey, TElement>> ToLookupAwaitWithCancellationAsync<TSource, TKey, TElement>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<TKey>> keySelector, Func<TSource, CancellationToken, UniTask<TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
{ {
var pool = ArrayPool<TSource>.Shared; var pool = ArrayPool<TSource>.Shared;
var array = pool.Rent(16); var array = pool.Rent(16);

View File

@ -48,17 +48,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _ToUniTaskAsyncEnumerable(source, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<T> class _ToUniTaskAsyncEnumerable : IUniTaskAsyncEnumerator<T>
{ {
readonly IEnumerable<T> source; readonly IEnumerable<T> source;
CancellationToken cancellationToken; CancellationToken cancellationToken;
IEnumerator<T> enumerator; IEnumerator<T> enumerator;
public Enumerator(IEnumerable<T> source, CancellationToken cancellationToken) public _ToUniTaskAsyncEnumerable(IEnumerable<T> source, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
@ -102,10 +102,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _ToUniTaskAsyncEnumerableTask(source, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<T> class _ToUniTaskAsyncEnumerableTask : IUniTaskAsyncEnumerator<T>
{ {
readonly Task<T> source; readonly Task<T> source;
CancellationToken cancellationToken; CancellationToken cancellationToken;
@ -113,7 +113,7 @@ namespace Cysharp.Threading.Tasks.Linq
T current; T current;
bool called; bool called;
public Enumerator(Task<T> source, CancellationToken cancellationToken) public _ToUniTaskAsyncEnumerableTask(Task<T> source, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
@ -155,10 +155,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _ToUniTaskAsyncEnumerableUniTask(source, cancellationToken);
} }
class Enumerator : IUniTaskAsyncEnumerator<T> class _ToUniTaskAsyncEnumerableUniTask : IUniTaskAsyncEnumerator<T>
{ {
readonly UniTask<T> source; readonly UniTask<T> source;
CancellationToken cancellationToken; CancellationToken cancellationToken;
@ -166,7 +166,7 @@ namespace Cysharp.Threading.Tasks.Linq
T current; T current;
bool called; bool called;
public Enumerator(UniTask<T> source, CancellationToken cancellationToken) public _ToUniTaskAsyncEnumerableUniTask(UniTask<T> source, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
@ -208,10 +208,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, cancellationToken); return new _ToUniTaskAsyncEnumerableObservable(source, cancellationToken);
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<T>, IObserver<T> class _ToUniTaskAsyncEnumerableObservable : MoveNextSource, IUniTaskAsyncEnumerator<T>, IObserver<T>
{ {
static readonly Action<object> OnCanceledDelegate = OnCanceled; static readonly Action<object> OnCanceledDelegate = OnCanceled;
@ -227,7 +227,7 @@ namespace Cysharp.Threading.Tasks.Linq
IDisposable subscription; IDisposable subscription;
CancellationTokenRegistration cancellationTokenRegistration; CancellationTokenRegistration cancellationTokenRegistration;
public Enumerator(IObservable<T> source, CancellationToken cancellationToken) public _ToUniTaskAsyncEnumerableObservable(IObservable<T> source, CancellationToken cancellationToken)
{ {
this.source = source; this.source = source;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
@ -334,7 +334,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void OnCanceled(object state) static void OnCanceled(object state)
{ {
var self = (Enumerator)state; var self = (_ToUniTaskAsyncEnumerableObservable)state;
lock (self.queuedResult) lock (self.queuedResult)
{ {
self.completionSource.TrySetCanceled(self.cancellationToken); self.completionSource.TrySetCanceled(self.cancellationToken);

View File

@ -24,17 +24,17 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<AsyncUnit> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<AsyncUnit> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(updateTiming, cancellationToken); return new _EveryUpdate(updateTiming, cancellationToken);
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>, IPlayerLoopItem class _EveryUpdate : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>, IPlayerLoopItem
{ {
readonly PlayerLoopTiming updateTiming; readonly PlayerLoopTiming updateTiming;
CancellationToken cancellationToken; CancellationToken cancellationToken;
bool disposed; bool disposed;
public Enumerator(PlayerLoopTiming updateTiming, CancellationToken cancellationToken) public _EveryUpdate(PlayerLoopTiming updateTiming, CancellationToken cancellationToken)
{ {
this.updateTiming = updateTiming; this.updateTiming = updateTiming;

View File

@ -53,10 +53,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<AsyncUnit> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<AsyncUnit> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(dueTime, period, updateTiming, ignoreTimeScale, cancellationToken); return new _Timer(dueTime, period, updateTiming, ignoreTimeScale, cancellationToken);
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>, IPlayerLoopItem class _Timer : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>, IPlayerLoopItem
{ {
readonly float dueTime; readonly float dueTime;
readonly float? period; readonly float? period;
@ -68,7 +68,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool dueTimePhase; bool dueTimePhase;
bool disposed; bool disposed;
public Enumerator(TimeSpan dueTime, TimeSpan? period, PlayerLoopTiming updateTiming, bool ignoreTimeScale, CancellationToken cancellationToken) public _Timer(TimeSpan dueTime, TimeSpan? period, PlayerLoopTiming updateTiming, bool ignoreTimeScale, CancellationToken cancellationToken)
{ {
this.dueTime = (float)dueTime.TotalSeconds; this.dueTime = (float)dueTime.TotalSeconds;
this.period = (period == null) ? null : (float?)period.Value.TotalSeconds; this.period = (period == null) ? null : (float?)period.Value.TotalSeconds;
@ -161,10 +161,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<AsyncUnit> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<AsyncUnit> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(dueTimeFrameCount, periodFrameCount, updateTiming, cancellationToken); return new _TimerFrame(dueTimeFrameCount, periodFrameCount, updateTiming, cancellationToken);
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>, IPlayerLoopItem class _TimerFrame : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>, IPlayerLoopItem
{ {
readonly int dueTimeFrameCount; readonly int dueTimeFrameCount;
readonly int? periodFrameCount; readonly int? periodFrameCount;
@ -174,7 +174,7 @@ namespace Cysharp.Threading.Tasks.Linq
bool dueTimePhase; bool dueTimePhase;
bool disposed; bool disposed;
public Enumerator(int dueTimeFrameCount, int? periodFrameCount, PlayerLoopTiming updateTiming, CancellationToken cancellationToken) public _TimerFrame(int dueTimeFrameCount, int? periodFrameCount, PlayerLoopTiming updateTiming, CancellationToken cancellationToken)
{ {
if (dueTimeFrameCount <= 0) dueTimeFrameCount = 0; if (dueTimeFrameCount <= 0) dueTimeFrameCount = 0;
if (periodFrameCount != null) if (periodFrameCount != null)

View File

@ -35,7 +35,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return new WhereAwaitInt<TSource>(source, predicate); return new WhereIntAwait<TSource>(source, predicate);
} }
public static IUniTaskAsyncEnumerable<TSource> WhereAwaitWithCancellation<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate) public static IUniTaskAsyncEnumerable<TSource> WhereAwaitWithCancellation<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Boolean>> predicate)
@ -43,7 +43,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return new WhereAwaitCancellation<TSource>(source, predicate); return new WhereAwaitWithCancellation<TSource>(source, predicate);
} }
public static IUniTaskAsyncEnumerable<TSource> WhereAwaitWithCancellation<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask<Boolean>> predicate) public static IUniTaskAsyncEnumerable<TSource> WhereAwaitWithCancellation<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32, CancellationToken, UniTask<Boolean>> predicate)
@ -51,7 +51,7 @@ namespace Cysharp.Threading.Tasks.Linq
Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(source));
Error.ThrowArgumentNullException(predicate, nameof(predicate)); Error.ThrowArgumentNullException(predicate, nameof(predicate));
return new WhereAwaitIntCancellation<TSource>(source, predicate); return new WhereIntAwaitWithCancellation<TSource>(source, predicate);
} }
} }
@ -68,14 +68,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _Where(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _Where : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly Func<TSource, bool> predicate; readonly Func<TSource, bool> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken) public _Where(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -118,15 +118,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _WhereInt(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorBase<TSource, TSource> class _WhereInt : AsyncEnumeratorBase<TSource, TSource>
{ {
readonly Func<TSource, int, bool> predicate; readonly Func<TSource, int, bool> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate, CancellationToken cancellationToken) public _WhereInt(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, bool> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -169,14 +169,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _WhereAwait(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _WhereAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
readonly Func<TSource, UniTask<bool>> predicate; readonly Func<TSource, UniTask<bool>> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<bool>> predicate, CancellationToken cancellationToken) public _WhereAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -204,12 +204,12 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class WhereAwaitInt<TSource> : IUniTaskAsyncEnumerable<TSource> internal sealed class WhereIntAwait<TSource> : IUniTaskAsyncEnumerable<TSource>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, int, UniTask<bool>> predicate; readonly Func<TSource, int, UniTask<bool>> predicate;
public WhereAwaitInt(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate) public WhereIntAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate)
{ {
this.source = source; this.source = source;
this.predicate = predicate; this.predicate = predicate;
@ -217,15 +217,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _WhereIntAwait(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _WhereIntAwait : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
readonly Func<TSource, int, UniTask<bool>> predicate; readonly Func<TSource, int, UniTask<bool>> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate, CancellationToken cancellationToken) public _WhereIntAwait(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -255,12 +255,12 @@ namespace Cysharp.Threading.Tasks.Linq
internal sealed class WhereAwaitCancellation<TSource> : IUniTaskAsyncEnumerable<TSource> internal sealed class WhereAwaitWithCancellation<TSource> : IUniTaskAsyncEnumerable<TSource>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, CancellationToken, UniTask<bool>> predicate; readonly Func<TSource, CancellationToken, UniTask<bool>> predicate;
public WhereAwaitCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate) public WhereAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate)
{ {
this.source = source; this.source = source;
this.predicate = predicate; this.predicate = predicate;
@ -268,14 +268,14 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _WhereAwaitWithCancellation(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _WhereAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
readonly Func<TSource, CancellationToken, UniTask<bool>> predicate; readonly Func<TSource, CancellationToken, UniTask<bool>> predicate;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken) public _WhereAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {
@ -303,12 +303,12 @@ namespace Cysharp.Threading.Tasks.Linq
} }
} }
internal sealed class WhereAwaitIntCancellation<TSource> : IUniTaskAsyncEnumerable<TSource> internal sealed class WhereIntAwaitWithCancellation<TSource> : IUniTaskAsyncEnumerable<TSource>
{ {
readonly IUniTaskAsyncEnumerable<TSource> source; readonly IUniTaskAsyncEnumerable<TSource> source;
readonly Func<TSource, int, CancellationToken, UniTask<bool>> predicate; readonly Func<TSource, int, CancellationToken, UniTask<bool>> predicate;
public WhereAwaitIntCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate) public WhereIntAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate)
{ {
this.source = source; this.source = source;
this.predicate = predicate; this.predicate = predicate;
@ -316,15 +316,15 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TSource> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(source, predicate, cancellationToken); return new _WhereIntAwaitWithCancellation(source, predicate, cancellationToken);
} }
class Enumerator : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool> class _WhereIntAwaitWithCancellation : AsyncEnumeratorAwaitSelectorBase<TSource, TSource, bool>
{ {
readonly Func<TSource, int, CancellationToken, UniTask<bool>> predicate; readonly Func<TSource, int, CancellationToken, UniTask<bool>> predicate;
int index; int index;
public Enumerator(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken) public _WhereIntAwaitWithCancellation(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, int, CancellationToken, UniTask<bool>> predicate, CancellationToken cancellationToken)
: base(source, cancellationToken) : base(source, cancellationToken)
{ {

View File

@ -58,10 +58,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(first, second, resultSelector, cancellationToken); return new _Zip(first, second, resultSelector, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _Zip : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> firstMoveNextCoreDelegate = FirstMoveNextCore; static readonly Action<object> firstMoveNextCoreDelegate = FirstMoveNextCore;
static readonly Action<object> secondMoveNextCoreDelegate = SecondMoveNextCore; static readonly Action<object> secondMoveNextCoreDelegate = SecondMoveNextCore;
@ -78,7 +78,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<bool>.Awaiter firstAwaiter; UniTask<bool>.Awaiter firstAwaiter;
UniTask<bool>.Awaiter secondAwaiter; UniTask<bool>.Awaiter secondAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TFirst> first, IUniTaskAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector, CancellationToken cancellationToken) public _Zip(IUniTaskAsyncEnumerable<TFirst> first, IUniTaskAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector, CancellationToken cancellationToken)
{ {
this.first = first; this.first = first;
this.second = second; this.second = second;
@ -114,7 +114,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void FirstMoveNextCore(object state) static void FirstMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_Zip)state;
if (self.TryGetResult(self.firstAwaiter, out var result)) if (self.TryGetResult(self.firstAwaiter, out var result))
{ {
@ -148,7 +148,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SecondMoveNextCore(object state) static void SecondMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_Zip)state;
if (self.TryGetResult(self.secondAwaiter, out var result)) if (self.TryGetResult(self.secondAwaiter, out var result))
{ {
@ -208,10 +208,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(first, second, resultSelector, cancellationToken); return new _ZipAwait(first, second, resultSelector, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _ZipAwait : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> firstMoveNextCoreDelegate = FirstMoveNextCore; static readonly Action<object> firstMoveNextCoreDelegate = FirstMoveNextCore;
static readonly Action<object> secondMoveNextCoreDelegate = SecondMoveNextCore; static readonly Action<object> secondMoveNextCoreDelegate = SecondMoveNextCore;
@ -230,7 +230,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<bool>.Awaiter secondAwaiter; UniTask<bool>.Awaiter secondAwaiter;
UniTask<TResult>.Awaiter resultAwaiter; UniTask<TResult>.Awaiter resultAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TFirst> first, IUniTaskAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, UniTask<TResult>> resultSelector, CancellationToken cancellationToken) public _ZipAwait(IUniTaskAsyncEnumerable<TFirst> first, IUniTaskAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, UniTask<TResult>> resultSelector, CancellationToken cancellationToken)
{ {
this.first = first; this.first = first;
this.second = second; this.second = second;
@ -266,7 +266,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void FirstMoveNextCore(object state) static void FirstMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_ZipAwait)state;
if (self.TryGetResult(self.firstAwaiter, out var result)) if (self.TryGetResult(self.firstAwaiter, out var result))
{ {
@ -300,7 +300,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SecondMoveNextCore(object state) static void SecondMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_ZipAwait)state;
if (self.TryGetResult(self.secondAwaiter, out var result)) if (self.TryGetResult(self.secondAwaiter, out var result))
{ {
@ -332,7 +332,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultAwaitCore(object state) static void ResultAwaitCore(object state)
{ {
var self = (Enumerator)state; var self = (_ZipAwait)state;
if (self.TryGetResult(self.resultAwaiter, out var result)) if (self.TryGetResult(self.resultAwaiter, out var result))
{ {
@ -378,10 +378,10 @@ namespace Cysharp.Threading.Tasks.Linq
public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<TResult> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(first, second, resultSelector, cancellationToken); return new _ZipAwaitWithCancellation(first, second, resultSelector, cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<TResult> sealed class _ZipAwaitWithCancellation : MoveNextSource, IUniTaskAsyncEnumerator<TResult>
{ {
static readonly Action<object> firstMoveNextCoreDelegate = FirstMoveNextCore; static readonly Action<object> firstMoveNextCoreDelegate = FirstMoveNextCore;
static readonly Action<object> secondMoveNextCoreDelegate = SecondMoveNextCore; static readonly Action<object> secondMoveNextCoreDelegate = SecondMoveNextCore;
@ -400,7 +400,7 @@ namespace Cysharp.Threading.Tasks.Linq
UniTask<bool>.Awaiter secondAwaiter; UniTask<bool>.Awaiter secondAwaiter;
UniTask<TResult>.Awaiter resultAwaiter; UniTask<TResult>.Awaiter resultAwaiter;
public Enumerator(IUniTaskAsyncEnumerable<TFirst> first, IUniTaskAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken) public _ZipAwaitWithCancellation(IUniTaskAsyncEnumerable<TFirst> first, IUniTaskAsyncEnumerable<TSecond> second, Func<TFirst, TSecond, CancellationToken, UniTask<TResult>> resultSelector, CancellationToken cancellationToken)
{ {
this.first = first; this.first = first;
this.second = second; this.second = second;
@ -436,7 +436,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void FirstMoveNextCore(object state) static void FirstMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_ZipAwaitWithCancellation)state;
if (self.TryGetResult(self.firstAwaiter, out var result)) if (self.TryGetResult(self.firstAwaiter, out var result))
{ {
@ -470,7 +470,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void SecondMoveNextCore(object state) static void SecondMoveNextCore(object state)
{ {
var self = (Enumerator)state; var self = (_ZipAwaitWithCancellation)state;
if (self.TryGetResult(self.secondAwaiter, out var result)) if (self.TryGetResult(self.secondAwaiter, out var result))
{ {
@ -502,7 +502,7 @@ namespace Cysharp.Threading.Tasks.Linq
static void ResultAwaitCore(object state) static void ResultAwaitCore(object state)
{ {
var self = (Enumerator)state; var self = (_ZipAwaitWithCancellation)state;
if (self.TryGetResult(self.resultAwaiter, out var result)) if (self.TryGetResult(self.resultAwaiter, out var result))
{ {

View File

@ -55,10 +55,10 @@ namespace Cysharp.Threading.Tasks.Triggers
public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default) public IUniTaskAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{ {
return new Enumerator(GetTriggerEvent(), cancellationToken); return new AsyncTriggerEnumerator(GetTriggerEvent(), cancellationToken);
} }
sealed class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<T>, IResolveCancelPromise<T> sealed class AsyncTriggerEnumerator : MoveNextSource, IUniTaskAsyncEnumerator<T>, IResolveCancelPromise<T>
{ {
static Action<object> cancellationCallback = CancellationCallback; static Action<object> cancellationCallback = CancellationCallback;
@ -68,7 +68,7 @@ namespace Cysharp.Threading.Tasks.Triggers
bool called; bool called;
bool isDisposed; bool isDisposed;
public Enumerator(TriggerEvent<T> triggerEvent, CancellationToken cancellationToken) public AsyncTriggerEnumerator(TriggerEvent<T> triggerEvent, CancellationToken cancellationToken)
{ {
this.triggerEvent = triggerEvent; this.triggerEvent = triggerEvent;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
@ -87,7 +87,7 @@ namespace Cysharp.Threading.Tasks.Triggers
static void CancellationCallback(object state) static void CancellationCallback(object state)
{ {
var self = (Enumerator)state; var self = (AsyncTriggerEnumerator)state;
self.DisposeAsync().Forget(); // sync self.DisposeAsync().Forget(); // sync
self.completionSource.TrySetCanceled(self.cancellationToken); self.completionSource.TrySetCanceled(self.cancellationToken);

View File

@ -489,15 +489,15 @@ namespace Cysharp.Threading.Tasks
{ {
if (this.cancellationToken1 == cancellationToken) if (this.cancellationToken1 == cancellationToken)
{ {
return new Enumerator(unityEvent, this.cancellationToken1, CancellationToken.None); return new UnityEventHandlerAsyncEnumerator(unityEvent, this.cancellationToken1, CancellationToken.None);
} }
else else
{ {
return new Enumerator(unityEvent, this.cancellationToken1, cancellationToken); return new UnityEventHandlerAsyncEnumerator(unityEvent, this.cancellationToken1, cancellationToken);
} }
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit> class UnityEventHandlerAsyncEnumerator : MoveNextSource, IUniTaskAsyncEnumerator<AsyncUnit>
{ {
static readonly Action<object> cancel1 = OnCanceled1; static readonly Action<object> cancel1 = OnCanceled1;
static readonly Action<object> cancel2 = OnCanceled2; static readonly Action<object> cancel2 = OnCanceled2;
@ -511,7 +511,7 @@ namespace Cysharp.Threading.Tasks
CancellationTokenRegistration registration2; CancellationTokenRegistration registration2;
bool isDisposed; bool isDisposed;
public Enumerator(UnityEvent unityEvent, CancellationToken cancellationToken1, CancellationToken cancellationToken2) public UnityEventHandlerAsyncEnumerator(UnityEvent unityEvent, CancellationToken cancellationToken1, CancellationToken cancellationToken2)
{ {
this.unityEvent = unityEvent; this.unityEvent = unityEvent;
this.cancellationToken1 = cancellationToken1; this.cancellationToken1 = cancellationToken1;
@ -552,13 +552,13 @@ namespace Cysharp.Threading.Tasks
static void OnCanceled1(object state) static void OnCanceled1(object state)
{ {
var self = (Enumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); self.DisposeAsync().Forget();
} }
static void OnCanceled2(object state) static void OnCanceled2(object state)
{ {
var self = (Enumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); self.DisposeAsync().Forget();
} }
@ -593,15 +593,15 @@ namespace Cysharp.Threading.Tasks
{ {
if (this.cancellationToken1 == cancellationToken) if (this.cancellationToken1 == cancellationToken)
{ {
return new Enumerator(unityEvent, this.cancellationToken1, CancellationToken.None); return new UnityEventHandlerAsyncEnumerator(unityEvent, this.cancellationToken1, CancellationToken.None);
} }
else else
{ {
return new Enumerator(unityEvent, this.cancellationToken1, cancellationToken); return new UnityEventHandlerAsyncEnumerator(unityEvent, this.cancellationToken1, cancellationToken);
} }
} }
class Enumerator : MoveNextSource, IUniTaskAsyncEnumerator<T> class UnityEventHandlerAsyncEnumerator : MoveNextSource, IUniTaskAsyncEnumerator<T>
{ {
static readonly Action<object> cancel1 = OnCanceled1; static readonly Action<object> cancel1 = OnCanceled1;
static readonly Action<object> cancel2 = OnCanceled2; static readonly Action<object> cancel2 = OnCanceled2;
@ -615,7 +615,7 @@ namespace Cysharp.Threading.Tasks
CancellationTokenRegistration registration2; CancellationTokenRegistration registration2;
bool isDisposed; bool isDisposed;
public Enumerator(UnityEvent<T> unityEvent, CancellationToken cancellationToken1, CancellationToken cancellationToken2) public UnityEventHandlerAsyncEnumerator(UnityEvent<T> unityEvent, CancellationToken cancellationToken1, CancellationToken cancellationToken2)
{ {
this.unityEvent = unityEvent; this.unityEvent = unityEvent;
this.cancellationToken1 = cancellationToken1; this.cancellationToken1 = cancellationToken1;
@ -657,13 +657,13 @@ namespace Cysharp.Threading.Tasks
static void OnCanceled1(object state) static void OnCanceled1(object state)
{ {
var self = (Enumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); self.DisposeAsync().Forget();
} }
static void OnCanceled2(object state) static void OnCanceled2(object state)
{ {
var self = (Enumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); self.DisposeAsync().Forget();
} }

View File

@ -151,7 +151,10 @@ public class SandboxMain : MonoBehaviour
await UniTask.Yield(PlayerLoopTiming.Update); await UniTask.Yield(PlayerLoopTiming.Update);
Debug.Log("Start:" + Time.frameCount); Debug.Log("Start:" + Time.frameCount);
await UniTaskAsyncEnumerable.TimerFrame(3, 5, PlayerLoopTiming.Update).ForEachAsync(_ => await UniTaskAsyncEnumerable.TimerFrame(3, 5, PlayerLoopTiming.PostLateUpdate)
.Select(x => x)
.Do(x => Debug.Log("DODODO"))
.ForEachAsync(_ =>
{ {
Debug.Log("Call:" + Time.frameCount); Debug.Log("Call:" + Time.frameCount);
}, cancellationToken: this.GetCancellationTokenOnDestroy()); }, cancellationToken: this.GetCancellationTokenOnDestroy());