using System; using System.Threading; using Cysharp.Threading.Tasks.Internal; namespace Cysharp.Threading.Tasks.Linq { public static partial class UniTaskAsyncEnumerable { public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Min.MinAsync(source, cancellationToken); } public static UniTask MinAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAsync(source, selector, cancellationToken); } public static UniTask MinAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitAsync(source, selector, cancellationToken); } public static UniTask MinAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken); } } internal static partial class Min { public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MinAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value > x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } } public static partial class UniTaskAsyncEnumerable { public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); return Max.MaxAsync(source, cancellationToken); } public static UniTask MaxAsync(this IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitAsync(source, selector, cancellationToken); } public static UniTask MaxAwaitWithCancellationAsync(this IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { Error.ThrowArgumentNullException(source, nameof(source)); Error.ThrowArgumentNullException(source, nameof(selector)); return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken); } } internal static partial class Max { public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64 value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); goto NEXT_LOOP; } throw Error.NoElements(); NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int32? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Int64? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Single? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Double? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = e.Current; if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = e.Current; if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAsync(IUniTaskAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } public static async UniTask MaxAwaitWithCancellationAsync(IUniTaskAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { Decimal? value = default; var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync()) { value = await selector(e.Current, cancellationToken); if(value == null) continue; goto NEXT_LOOP; } return default; NEXT_LOOP: while (await e.MoveNextAsync()) { var x = await selector(e.Current, cancellationToken); if( x == null) continue; if (value < x) { value = x; } } } finally { if (e != null) { await e.DisposeAsync(); } } return value; } } }