diff --git a/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt b/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt index b7e4c58d..4e255eec 100644 --- a/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt +++ b/Generators/SuperLinq.Async.Generator/EquiZip.sbntxt @@ -1,9 +1,8 @@ -{{ - $arity = arity - $ordinals = ordinals - $cardinals = cardinals -}} - +{{~ + $arity = arity + $ordinals = ordinals + $cardinals = cardinals +~}} namespace SuperLinq.Async; #nullable enable @@ -11,54 +10,57 @@ namespace SuperLinq.Async; public static partial class AsyncSuperEnumerable { {{~ for $i in 2..4 ~}} - /// + /// /// /// Applies a specified function to the corresponding elements of {{ $ordinals[$i] }} sequences, /// producing a sequence of the results. /// /// The resulting sequence has the same length as the input sequences. /// If the input sequences are of different lengths, an exception is thrown. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and stream its results. - /// - /// or any of the input sequences is null. - /// + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and stream its results. + /// + /// or any of the input sequences is null. + /// /// Any of the input sequences are shorter than the others. /// {{~ for $j in 1..$i ~}} - /// The type of the elements of . + /// The type of the elements of . /// The {{ $ordinals[$j] }} sequence of elements. {{~ end ~}} - public static global::System.Collections.Generic.IAsyncEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IAsyncEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static async global::System.Collections.Generic.IAsyncEnumerable Core( {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, {{~ end ~}} global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector, - [EnumeratorCancellation] CancellationToken cancellationToken = default) + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) { {{~ for $j in 1..$i ~}} await using var e{{ $j }} = {{ $ordinals[$j] }}.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); @@ -75,10 +77,10 @@ public static partial class AsyncSuperEnumerable || await e{{$j}}.MoveNextAsync() {{~ end end ~}} - ) + ) { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } yield break; } @@ -101,26 +103,27 @@ public static partial class AsyncSuperEnumerable /// /// Joins the corresponding elements of {{ $ordinals[$i] }} sequences, /// producing a sequence of tuples containing them. - /// - /// A sequence of + /// + /// A sequence of /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and stream its results. - /// - /// Any of the input sequences is null. - /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and stream its results. + /// + /// Any of the input sequences is null. + /// /// Any of the input sequences are shorter than the others. /// {{~ for $j in 1..$i ~}} - /// The type of the elements of . + /// The type of the elements of . /// The {{ $ordinals[$j] }} sequence of elements. {{~ end ~}} - public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> EquiZip<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); - {{ end ~}} + {{~ end ~}} + ) => EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Async.Generator/Fold.sbntxt b/Generators/SuperLinq.Async.Generator/Fold.sbntxt index d21beae2..f59bf973 100644 --- a/Generators/SuperLinq.Async.Generator/Fold.sbntxt +++ b/Generators/SuperLinq.Async.Generator/Fold.sbntxt @@ -1,41 +1,39 @@ -namespace SuperLinq.Async; +namespace SuperLinq.Async; #nullable enable public static partial class AsyncSuperEnumerable { {{~ for $i in 1..16 ~}} - /// - /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// + /// + /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// /// does not contain exactly {{$i}} element{{if $i != 1}}s{{end}}. /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func< - {{~ for $j in 1..$i ~}} - T, - {{~ end ~}} - TResult> folder) - { + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func<{{~ for $j in 1..$i ~}}T, {{ end ~}}TResult> folder + ) + { ArgumentNullException.ThrowIfNull(source); ArgumentNullException.ThrowIfNull(folder); return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func< - {{~ for $j in 1..$i ~}} - T, - {{~ end ~}} - TResult> folder) + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func<{{~ for $j in 1..$i ~}}T, {{ end ~}}TResult> folder + ) { var elements = await source.AssertCount({{$i}}).ToListAsync().ConfigureAwait(false); @@ -46,5 +44,6 @@ public static partial class AsyncSuperEnumerable ); } } - {{ end ~}} + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Async.Generator/Generator.cs b/Generators/SuperLinq.Async.Generator/Generator.cs index fd96595d..8fb4cd13 100644 --- a/Generators/SuperLinq.Async.Generator/Generator.cs +++ b/Generators/SuperLinq.Async.Generator/Generator.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; using Scriban; @@ -28,14 +28,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context) private static SourceText GenerateArgumentNamesTemplate(string template) { var output = Template.Parse(template).Render(ArgumentNames.Instance); - - // Apply formatting since indenting isn't that nice in Scriban when rendering nested - // structures via functions. - output = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseCompilationUnit(output) - .NormalizeWhitespace() - .GetText() - .ToString(); - return SourceText.From(output, Encoding.UTF8); } } diff --git a/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt b/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt index fca200a4..f8f19ec1 100644 --- a/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt +++ b/Generators/SuperLinq.Async.Generator/ZipLongest.sbntxt @@ -1,9 +1,8 @@ -{{ - $arity = arity - $ordinals = ordinals - $cardinals = cardinals -}} - +{{~ + $arity = arity + $ordinals = ordinals + $cardinals = cardinals +~}} namespace SuperLinq.Async; #nullable enable @@ -11,50 +10,53 @@ namespace SuperLinq.Async; public static partial class AsyncSuperEnumerable { {{~ for $i in 2..4 ~}} - /// + /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. The resulting sequence /// will always be as long as the longest of input sequences where the /// default value of each of the shorter sequence element types is used /// for padding. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. {{~ for $j in 1..$i ~}} - /// The type of the elements of . + /// The type of the elements of . /// The {{ $ordinals[$j] }} sequence of elements. {{~ end ~}} - public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static async global::System.Collections.Generic.IAsyncEnumerable Core( {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, {{~ end ~}} global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector, - [EnumeratorCancellation] CancellationToken cancellationToken = default) + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) { {{~ for $j in 1..$i ~}} await using var e{{ $j }} = {{ $ordinals[$j] }}.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); @@ -68,7 +70,7 @@ public static partial class AsyncSuperEnumerable ? e{{ $j }}.Current : default(T{{ $j }}); {{~ end ~}} - if (!f1 {{ for $j in 2..$i }}&& !f{{ $j }}{{ end }}) + if (!f1{{ for $j in 2..$i }} && !f{{ $j }}{{ end }}) yield break; yield return resultSelector( @@ -86,23 +88,24 @@ public static partial class AsyncSuperEnumerable /// will always be as long as the longest of input sequences where the /// default value of each of the shorter sequence element types is used /// for padding. - /// - /// A sequence of + /// + /// A sequence of /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. {{~ for $j in 1..$i ~}} - /// The type of the elements of . + /// The type of the elements of . /// The {{ $ordinals[$j] }} sequence of elements. {{~ end ~}} - public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})> ZipLongest<{{~ for $j in 1..$i ~}}T{{ $j }}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); - {{ end ~}} + {{~ end ~}} + ) => ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt b/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt index 1e4b1644..950612b2 100644 --- a/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt +++ b/Generators/SuperLinq.Async.Generator/ZipShortest.sbntxt @@ -1,9 +1,8 @@ -{{ - $arity = arity - $ordinals = ordinals - $cardinals = cardinals -}} - +{{~ + $arity = arity + $ordinals = ordinals + $cardinals = cardinals +~}} namespace SuperLinq.Async; #nullable enable @@ -11,48 +10,51 @@ namespace SuperLinq.Async; public static partial class AsyncSuperEnumerable { {{~ for $i in 2..4 ~}} - /// + /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. The resulting sequence /// is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. {{~ for $j in 1..$i ~}} - /// The type of the elements of . + /// The type of the elements of . /// The {{ $ordinals[$j] }} sequence of elements. {{~ end ~}} - public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static async global::System.Collections.Generic.IAsyncEnumerable Core( {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}, {{~ end ~}} global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector, - [EnumeratorCancellation] CancellationToken cancellationToken = default) + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) { {{~ for $j in 1..$i ~}} await using var e{{ $j }} = {{ $ordinals[$j] }}.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); @@ -60,8 +62,7 @@ public static partial class AsyncSuperEnumerable while ( {{~ for $j in 1..$i ~}} - {{ if !for.first }}&&{{ end }} - await e{{$j}}.MoveNextAsync() + {{ if !for.first }}&& {{ end }}await e{{$j}}.MoveNextAsync() {{~ end ~}} ) { @@ -80,23 +81,24 @@ public static partial class AsyncSuperEnumerable /// will always be as long as the longest of input sequences where the /// default value of each of the shorter sequence element types is used /// for padding. - /// - /// A sequence of + /// + /// A sequence of /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. {{~ for $j in 1..$i ~}} - /// The type of the elements of . + /// The type of the elements of . /// The {{ $ordinals[$j] }} sequence of elements. {{~ end ~}} - public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IAsyncEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> ZipShortest<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IAsyncEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); - {{ end ~}} + {{~ end ~}} + ) => ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Generator/Aggregate.sbntxt b/Generators/SuperLinq.Generator/Aggregate.sbntxt index 328c6e3c..197f79c7 100644 --- a/Generators/SuperLinq.Generator/Aggregate.sbntxt +++ b/Generators/SuperLinq.Generator/Aggregate.sbntxt @@ -1,8 +1,7 @@ -{{ - $arity = arity - $ordinals = ordinals -}} - +{{~ + $arity = arity + $ordinals = ordinals +~}} namespace SuperLinq; #nullable enable @@ -10,83 +9,84 @@ namespace SuperLinq; public static partial class SuperEnumerable { {{~ for $i in 2..($arity.size - 1) ~}} - /// - /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. + /// + /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// /// , or any of the accumulator functions is null. /// {{~ for $j in 1..$i ~}} - /// The type of the {{ $ordinals[$j] }} accumulator value. + /// The type of the {{ $ordinals[$j] }} accumulator value. /// The seed value for the {{ $ordinals[$j] }} accumulator. /// The {{ $ordinals[$j] }} accumulator. {{~ end ~}} - public static TResult Aggregate( - this global::System.Collections.Generic.IEnumerable source, + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, {{~ for $j in 1..$i ~}} - TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}}, + TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}TAccumulate{{$j}}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}TAccumulate{{$j}}, {{ end }}TResult> resultSelector + ) { ArgumentNullException.ThrowIfNull(source); {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull(accumulator{{$j}}); + ArgumentNullException.ThrowIfNull(accumulator{{$j}}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); foreach (var item in source) { {{~ for $j in 1..$i ~}} - seed{{$j}} = accumulator{{$j}}(seed{{$j}}, item); - {{~ end ~}} + seed{{$j}} = accumulator{{$j}}(seed{{$j}}, item); + {{~ end ~}} } return resultSelector( {{~ for $j in 1..$i ~}} - seed{{$j}}{{ if !for.last }},{{ end }} - {{~ end ~}} - ); + seed{{$j}}{{ if !for.last }},{{ end }} + {{~ end ~}} + ); } - /// - /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A + /// + /// Applies {{ $arity[$i] }} accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// /// or any of the accumulator functions is null. /// {{~ for $j in 1..$i ~}} - /// The type of the {{ $ordinals[$j] }} accumulator value. + /// The type of the {{ $ordinals[$j] }} accumulator value. /// The seed value for the {{ $ordinals[$j] }} accumulator. /// The {{ $ordinals[$j] }} accumulator. {{~ end ~}} - public static ({{~ for $j in 1..$i ~}}TAccumulate{{$j}}{{ if !for.last }},{{ end }}{{ end }}) Aggregate( - this global::System.Collections.Generic.IEnumerable source, + public static ({{~ for $j in 1..$i ~}}TAccumulate{{$j}}{{ if !for.last }},{{ end }}{{ end }}) Aggregate( + this global::System.Collections.Generic.IEnumerable source, {{~ for $j in 1..$i ~}} - TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - Aggregate(source, {{~ for $j in 1..$i ~}}seed{{$j}}, accumulator{{$j}}, {{ end }}global::System.ValueTuple.Create); + TAccumulate{{$j}} seed{{$j}}, global::System.Func accumulator{{$j}}{{ if !for.last }},{{ end }} + {{~ end ~}} + ) => Aggregate(source, {{~ for $j in 1..$i ~}}seed{{$j}}, accumulator{{$j}}, {{ end }}global::System.ValueTuple.Create); - {{ end ~}} + {{~ end ~}} } diff --git a/Generators/SuperLinq.Generator/Cartesian.sbntxt b/Generators/SuperLinq.Generator/Cartesian.sbntxt index c7a83e63..e15f56cb 100644 --- a/Generators/SuperLinq.Generator/Cartesian.sbntxt +++ b/Generators/SuperLinq.Generator/Cartesian.sbntxt @@ -1,8 +1,7 @@ -{{ - $arity = arity - $ordinals = ordinals -}} - +{{~ + $arity = arity + $ordinals = ordinals +~}} namespace SuperLinq; #nullable enable @@ -10,56 +9,58 @@ namespace SuperLinq; public static partial class SuperEnumerable { {{~ for $i in 2..($arity.size - 1) ~}} - /// - /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. + /// + /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. /// - /// + /// /// A projection function that combines elements from all of the sequences. /// - /// + /// /// A sequence of elements returned by . /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. /// - /// - /// This method uses deferred execution and stream its results. + /// + /// This method uses deferred execution and stream its results. /// - /// - /// + /// + /// /// or any of the input sequences is . /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable Cartesian<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IEnumerable Cartesian<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{$j}}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static global::System.Collections.Generic.IEnumerable Core( {{~ for $j in 1..$i ~}} @@ -74,47 +75,50 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} foreach (var item{{$j}} in {{ $ordinals[$j] }}Memo) {{~ end ~}} + { yield return resultSelector( {{~ for $j in 1..$i ~}} item{{$j}}{{ if !for.last }},{{ end }} {{~ end ~}} ); + } } } /// - /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// + /// Returns the Cartesian product of {{ $arity[$i] }} sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// /// A sequence of containing elements from each of the /// sequences. /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. /// - /// - /// This method uses deferred execution and stream its results. + /// + /// This method uses deferred execution and stream its results. /// - /// - /// + /// + /// /// Any of the input sequences is . /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{$j}}{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{$j}}{{ if !for.last }},{{ end }}{{ end }})> Cartesian<{{~ for $j in 1..$i ~}}T{{$j}}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - Cartesian({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); - {{ end ~}} + {{~ end ~}} + ) => Cartesian({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Generator/EquiZip.sbntxt b/Generators/SuperLinq.Generator/EquiZip.sbntxt index 7e5628a3..2aafc0cc 100644 --- a/Generators/SuperLinq.Generator/EquiZip.sbntxt +++ b/Generators/SuperLinq.Generator/EquiZip.sbntxt @@ -1,9 +1,8 @@ -{{ - $arity = arity - $ordinals = ordinals - $cardinals = cardinals -}} - +{{~ + $arity = arity + $ordinals = ordinals + $cardinals = cardinals +~}} namespace SuperLinq; #nullable enable @@ -40,24 +39,25 @@ public static partial class SuperEnumerable /// Any of the input sequences are shorter than the others. /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IEnumerable EquiZip<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); if ( {{~ for $j in 1..$i ~}} @@ -68,20 +68,23 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} list{{ $j }}, {{~ end ~}} - resultSelector); + resultSelector + ); } return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static global::System.Collections.Generic.IEnumerable Core( {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} using var e{{ $j }} = {{ $ordinals[$j] }}.GetEnumerator(); @@ -98,10 +101,10 @@ public static partial class SuperEnumerable || e{{$j}}.MoveNext() {{~ end end ~}} - ) + ) { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } yield break; } @@ -121,36 +124,36 @@ public static partial class SuperEnumerable } } - /// - /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. - /// - /// + /// + /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. + /// + /// /// A sequence of /// containing corresponding elements from each of the sequences. /// - /// - /// This method uses deferred execution and stream its results. - /// - /// + /// + /// This method uses deferred execution and stream its results. + /// + /// /// Any of the input sequences is null. /// - /// - /// Any of the input sequences are shorter than the others. - /// + /// + /// Any of the input sequences are shorter than the others. + /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> EquiZip<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + {{~ end ~}} + ) => EquiZip({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); private class EquiZipIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator { @@ -163,7 +166,8 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IList {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} _list{{ $j }} = {{ $ordinals[$j] }}; @@ -197,7 +201,8 @@ public static partial class SuperEnumerable yield return _resultSelector( {{~ for $j in 1..$i ~}} _list{{ $j }}[i]{{ if !for.last }}, {{ end }} - {{~ end ~}}); + {{~ end ~}} + ); } } @@ -209,8 +214,10 @@ public static partial class SuperEnumerable return _resultSelector( {{~ for $j in 1..$i ~}} _list{{ $j }}[index]{{ if !for.last }}, {{ end }} - {{~ end ~}}); + {{~ end ~}} + ); } } - {{ end ~}} + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Generator/Fold.sbntxt b/Generators/SuperLinq.Generator/Fold.sbntxt index c89d22ab..b5465d52 100644 --- a/Generators/SuperLinq.Generator/Fold.sbntxt +++ b/Generators/SuperLinq.Generator/Fold.sbntxt @@ -1,43 +1,42 @@ -namespace SuperLinq; +namespace SuperLinq; #nullable enable public static partial class SuperEnumerable { {{~ for $i in 1..16 ~}} - /// - /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// + /// + /// Returns the result of applying a function to a sequence of {{$i}} element{{if $i != 1}}s{{end}}. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// /// Type of element in the source sequence /// - /// + /// /// Type of the result /// - /// + /// /// The sequence of items to fold. /// - /// + /// /// Function to apply to the elements in the sequence. /// - /// + /// /// The folded value returned by . /// - /// + /// /// or is . /// - /// + /// /// does not contain exactly {{$i}} element{{if $i != 1}}s{{end}}. /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func< - {{~ for $j in 1..$i ~}} - T, - {{~ end ~}} - TResult> folder) - { + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func<{{~ for $j in 1..$i ~}}T, {{ end ~}}TResult> folder + ) + { ArgumentNullException.ThrowIfNull(source); ArgumentNullException.ThrowIfNull(folder); @@ -49,5 +48,6 @@ public static partial class SuperEnumerable {{~ end ~}} ); } - {{ end ~}} + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Generator/Generator.cs b/Generators/SuperLinq.Generator/Generator.cs index d2aa44be..301b5ca0 100644 --- a/Generators/SuperLinq.Generator/Generator.cs +++ b/Generators/SuperLinq.Generator/Generator.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; using Scriban; @@ -33,14 +33,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context) private static SourceText GenerateArgumentNamesTemplate(string template) { var output = Template.Parse(template).Render(ArgumentNames.Instance); - - // Apply formatting since indenting isn't that nice in Scriban when rendering nested - // structures via functions. - output = Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseCompilationUnit(output) - .NormalizeWhitespace() - .GetText() - .ToString(); - return SourceText.From(output, Encoding.UTF8); } } diff --git a/Generators/SuperLinq.Generator/ZipLongest.sbntxt b/Generators/SuperLinq.Generator/ZipLongest.sbntxt index 3de942fc..29d266cf 100644 --- a/Generators/SuperLinq.Generator/ZipLongest.sbntxt +++ b/Generators/SuperLinq.Generator/ZipLongest.sbntxt @@ -1,9 +1,8 @@ -{{ - $arity = arity - $ordinals = ordinals - $cardinals = cardinals -}} - +{{~ + $arity = arity + $ordinals = ordinals + $cardinals = cardinals +~}} namespace SuperLinq; #nullable enable @@ -23,11 +22,11 @@ public static partial class SuperEnumerable } {{~ for $i in 2..4 ~}} - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// /// /// The type of the elements of the result sequence. /// @@ -40,28 +39,29 @@ public static partial class SuperEnumerable /// /// This method uses deferred execution and streams its results. /// - /// + /// /// or any of the input sequences is . /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IEnumerable ZipLongest<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); if ( {{~ for $j in 1..$i ~}} @@ -72,20 +72,23 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} list{{ $j }}, {{~ end ~}} - resultSelector); + resultSelector + ); } return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static global::System.Collections.Generic.IEnumerable Core( {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} using var e{{ $j }} = {{ $ordinals[$j] }}.GetEnumerator(); @@ -94,10 +97,9 @@ public static partial class SuperEnumerable while ( {{~ for $j in 1..$i ~}} - {{ if !for.first }}|{{ end }} - (f{{$j}} = DoRead(f{{$j}}, e{{$j}}, out var v{{$j}})) + {{ if !for.first }}| {{ end }}(f{{$j}} = DoRead(f{{$j}}, e{{$j}}, out var v{{$j}})) {{~ end ~}} - ) + ) { yield return resultSelector( {{~ for $j in 1..$i ~}} @@ -113,30 +115,30 @@ public static partial class SuperEnumerable /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default /// value of each of the shorter sequence element types is used for padding. /// - /// + /// /// A sequence of containing corresponding elements from each - /// of the sequences. + /// of the sequences. /// /// /// This method uses deferred execution and streams its results. /// - /// + /// /// Any of the input sequences is . /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $j }}?{{ if !for.last }},{{ end }}{{ end }})> ZipLongest<{{~ for $j in 1..$i ~}}T{{ $j }}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + {{~ end ~}} + ) => ZipLongest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); private sealed class ZipLongestIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator { @@ -149,7 +151,8 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IList {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $j }}?, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} _list{{ $j }} = {{ $ordinals[$j] }}; @@ -167,7 +170,8 @@ public static partial class SuperEnumerable yield return _resultSelector( {{~ for $j in 1..$i ~}} i < _list{{ $j }}.Count ? _list{{ $j }}[i] : default{{ if !for.last }}, {{ end }} - {{~ end ~}}); + {{~ end ~}} + ); } } @@ -179,8 +183,10 @@ public static partial class SuperEnumerable return _resultSelector( {{~ for $j in 1..$i ~}} index < _list{{ $j }}.Count ? _list{{ $j }}[index] : default{{ if !for.last }}, {{ end }} - {{~ end ~}}); + {{~ end ~}} + ); } } - {{ end ~}} + + {{~ end ~}} } diff --git a/Generators/SuperLinq.Generator/ZipShortest.sbntxt b/Generators/SuperLinq.Generator/ZipShortest.sbntxt index 2e1903f5..fab29157 100644 --- a/Generators/SuperLinq.Generator/ZipShortest.sbntxt +++ b/Generators/SuperLinq.Generator/ZipShortest.sbntxt @@ -1,9 +1,8 @@ -{{ - $arity = arity - $ordinals = ordinals - $cardinals = cardinals -}} - +{{~ + $arity = arity + $ordinals = ordinals + $cardinals = cardinals +~}} namespace SuperLinq; #nullable enable @@ -11,44 +10,45 @@ namespace SuperLinq; public static partial class SuperEnumerable { {{~ for $i in 2..4 ~}} - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. /// - /// + /// /// A projection function that combines elements from all of the sequences. /// - /// + /// /// A sequence of elements returned by . /// - /// - /// This method uses deferred execution and streams its results. - /// - /// + /// + /// This method uses deferred execution and streams its results. + /// + /// /// or any of the input sequences is . /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this + public static global::System.Collections.Generic.IEnumerable ZipShortest<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult>(this {{~ for $j in 1..$i ~}} - global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, + global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} - ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); + ArgumentNullException.ThrowIfNull({{ $ordinals[$j] }}); {{~ end ~}} - ArgumentNullException.ThrowIfNull(resultSelector); + ArgumentNullException.ThrowIfNull(resultSelector); if ( {{~ for $j in 1..$i ~}} @@ -59,20 +59,23 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} list{{ $j }}, {{~ end ~}} - resultSelector); + resultSelector + ); } return Core( {{~ for $j in 1..$i ~}} {{ $ordinals[$j] }}, {{~ end ~}} - resultSelector); + resultSelector + ); static global::System.Collections.Generic.IEnumerable Core( {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $cardinals[$j] }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} using var e{{ $j }} = {{ $ordinals[$j] }}.GetEnumerator(); @@ -80,8 +83,7 @@ public static partial class SuperEnumerable while ( {{~ for $j in 1..$i ~}} - {{ if !for.first }}&&{{ end }} - e{{$j}}.MoveNext() + {{ if !for.first }}&& {{ end }}e{{$j}}.MoveNext() {{~ end ~}} ) { @@ -95,34 +97,34 @@ public static partial class SuperEnumerable } /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// /// A sequence of containing corresponding elements from each - /// of the sequences. + /// of the sequences. /// /// - /// This method uses deferred execution and streams its results. - /// - /// + /// This method uses deferred execution and streams its results. + /// + /// /// Any of the input sequences is . /// {{~ for $j in 1..$i ~}} - /// + /// /// The type of the elements of . /// /// /// The {{ $ordinals[$j] }} sequence of elements. /// {{~ end ~}} - public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> + public static global::System.Collections.Generic.IEnumerable<({{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }})> ZipShortest<{{~ for $j in 1..$i ~}}T{{ $cardinals[$j] }}{{ if !for.last }},{{ end }}{{ end }}>(this {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IEnumerable {{ $ordinals[$j] }}{{ if !for.last }},{{ end }} - {{~ end ~}}) => - ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); + {{~ end ~}} + ) => ZipShortest({{~ for $j in 1..$i ~}}{{ $ordinals[$j] }}, {{ end }}global::System.ValueTuple.Create); private sealed class ZipShortestIterator<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> : ListIterator { @@ -135,7 +137,8 @@ public static partial class SuperEnumerable {{~ for $j in 1..$i ~}} global::System.Collections.Generic.IList {{ $ordinals[$j] }}, {{~ end ~}} - global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector) + global::System.Func<{{ for $j in 1..$i }}T{{ $j }}, {{ end }}TResult> resultSelector + ) { {{~ for $j in 1..$i ~}} _list{{ $j }} = {{ $ordinals[$j] }}; @@ -153,7 +156,8 @@ public static partial class SuperEnumerable yield return _resultSelector( {{~ for $j in 1..$i ~}} _list{{ $j }}[i]{{ if !for.last }}, {{ end }} - {{~ end ~}}); + {{~ end ~}} + ); } } @@ -165,8 +169,10 @@ public static partial class SuperEnumerable return _resultSelector( {{~ for $j in 1..$i ~}} _list{{ $j }}[index]{{ if !for.last }}, {{ end }} - {{~ end ~}}); + {{~ end ~}} + ); } } - {{ end ~}} + + {{~ end ~}} } diff --git a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs index a20bb288..8fa20477 100644 --- a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs +++ b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/EquiZip.g.cs @@ -1,245 +1,352 @@ namespace SuperLinq.Async; + #nullable enable + public static partial class AsyncSuperEnumerable { - /// - /// - /// Applies a specified function to the corresponding elements of second sequences, - /// producing a sequence of the results. - /// - /// The resulting sequence has the same length as the input sequences. - /// If the input sequences are of different lengths, an exception is thrown. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and stream its results. - /// - /// or any of the input sequences is null. - /// - /// Any of the input sequences are shorter than the others. - /// - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - while (true) - { - if (!await e1.MoveNextAsync()) - { - if (await e2.MoveNextAsync()) - { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } - - yield break; - } - - if (!await e2.MoveNextAsync()) - ThrowHelper.ThrowInvalidOperationException("Second sequence too short."); - yield return resultSelector(e1.Current, e2.Current); - } - } - } - - /// - /// Joins the corresponding elements of second sequences, - /// producing a sequence of tuples containing them. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and stream its results. - /// - /// Any of the input sequences is null. - /// - /// Any of the input sequences are shorter than the others. - /// - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond)> EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second) => EquiZip(first, second, global::System.ValueTuple.Create); - /// - /// - /// Applies a specified function to the corresponding elements of third sequences, - /// producing a sequence of the results. - /// - /// The resulting sequence has the same length as the input sequences. - /// If the input sequences are of different lengths, an exception is thrown. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and stream its results. - /// - /// or any of the input sequences is null. - /// - /// Any of the input sequences are shorter than the others. - /// - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - while (true) - { - if (!await e1.MoveNextAsync()) - { - if (await e2.MoveNextAsync() || await e3.MoveNextAsync()) - { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } - - yield break; - } - - if (!await e2.MoveNextAsync()) - ThrowHelper.ThrowInvalidOperationException("Second sequence too short."); - if (!await e3.MoveNextAsync()) - ThrowHelper.ThrowInvalidOperationException("Third sequence too short."); - yield return resultSelector(e1.Current, e2.Current, e3.Current); - } - } - } - - /// - /// Joins the corresponding elements of third sequences, - /// producing a sequence of tuples containing them. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and stream its results. - /// - /// Any of the input sequences is null. - /// - /// Any of the input sequences are shorter than the others. - /// - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond, TThird)> EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third) => EquiZip(first, second, third, global::System.ValueTuple.Create); - /// - /// - /// Applies a specified function to the corresponding elements of fourth sequences, - /// producing a sequence of the results. - /// - /// The resulting sequence has the same length as the input sequences. - /// If the input sequences are of different lengths, an exception is thrown. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and stream its results. - /// - /// or any of the input sequences is null. - /// - /// Any of the input sequences are shorter than the others. - /// - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - /// The type of the elements of . - /// The fourth sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - while (true) - { - if (!await e1.MoveNextAsync()) - { - if (await e2.MoveNextAsync() || await e3.MoveNextAsync() || await e4.MoveNextAsync()) - { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } - - yield break; - } - - if (!await e2.MoveNextAsync()) - ThrowHelper.ThrowInvalidOperationException("Second sequence too short."); - if (!await e3.MoveNextAsync()) - ThrowHelper.ThrowInvalidOperationException("Third sequence too short."); - if (!await e4.MoveNextAsync()) - ThrowHelper.ThrowInvalidOperationException("Fourth sequence too short."); - yield return resultSelector(e1.Current, e2.Current, e3.Current, e4.Current); - } - } - } - - /// - /// Joins the corresponding elements of fourth sequences, - /// producing a sequence of tuples containing them. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and stream its results. - /// - /// Any of the input sequences is null. - /// - /// Any of the input sequences are shorter than the others. - /// - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - /// The type of the elements of . - /// The fourth sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond, TThird, TFourth)> EquiZip(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create); -} \ No newline at end of file + /// + /// + /// Applies a specified function to the corresponding elements of second sequences, + /// producing a sequence of the results. + /// + /// The resulting sequence has the same length as the input sequences. + /// If the input sequences are of different lengths, an exception is thrown. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and stream its results. + /// + /// or any of the input sequences is null. + /// + /// Any of the input sequences are shorter than the others. + /// + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + + while (true) + { + if (!await e1.MoveNextAsync()) + { + if (await e2.MoveNextAsync() + ) + { + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } + + yield break; + } + + if (!await e2.MoveNextAsync()) + ThrowHelper.ThrowInvalidOperationException( + "Second sequence too short."); + + yield return resultSelector( + e1.Current, + e2.Current + ); + } + } + } + + /// + /// Joins the corresponding elements of second sequences, + /// producing a sequence of tuples containing them. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and stream its results. + /// + /// Any of the input sequences is null. + /// + /// Any of the input sequences are shorter than the others. + /// + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond)> + EquiZip(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second + ) => EquiZip(first, second, global::System.ValueTuple.Create); + + /// + /// + /// Applies a specified function to the corresponding elements of third sequences, + /// producing a sequence of the results. + /// + /// The resulting sequence has the same length as the input sequences. + /// If the input sequences are of different lengths, an exception is thrown. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and stream its results. + /// + /// or any of the input sequences is null. + /// + /// Any of the input sequences are shorter than the others. + /// + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + + while (true) + { + if (!await e1.MoveNextAsync()) + { + if (await e2.MoveNextAsync() + || await e3.MoveNextAsync() + ) + { + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } + + yield break; + } + + if (!await e2.MoveNextAsync()) + ThrowHelper.ThrowInvalidOperationException( + "Second sequence too short."); + if (!await e3.MoveNextAsync()) + ThrowHelper.ThrowInvalidOperationException( + "Third sequence too short."); + + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current + ); + } + } + } + + /// + /// Joins the corresponding elements of third sequences, + /// producing a sequence of tuples containing them. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and stream its results. + /// + /// Any of the input sequences is null. + /// + /// Any of the input sequences are shorter than the others. + /// + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond,TThird)> + EquiZip(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third + ) => EquiZip(first, second, third, global::System.ValueTuple.Create); + + /// + /// + /// Applies a specified function to the corresponding elements of fourth sequences, + /// producing a sequence of the results. + /// + /// The resulting sequence has the same length as the input sequences. + /// If the input sequences are of different lengths, an exception is thrown. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and stream its results. + /// + /// or any of the input sequences is null. + /// + /// Any of the input sequences are shorter than the others. + /// + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + /// The type of the elements of . + /// The fourth sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable EquiZip(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + + while (true) + { + if (!await e1.MoveNextAsync()) + { + if (await e2.MoveNextAsync() + || await e3.MoveNextAsync() + || await e4.MoveNextAsync() + ) + { + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } + + yield break; + } + + if (!await e2.MoveNextAsync()) + ThrowHelper.ThrowInvalidOperationException( + "Second sequence too short."); + if (!await e3.MoveNextAsync()) + ThrowHelper.ThrowInvalidOperationException( + "Third sequence too short."); + if (!await e4.MoveNextAsync()) + ThrowHelper.ThrowInvalidOperationException( + "Fourth sequence too short."); + + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current, + e4.Current + ); + } + } + } + + /// + /// Joins the corresponding elements of fourth sequences, + /// producing a sequence of tuples containing them. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and stream its results. + /// + /// Any of the input sequences is null. + /// + /// Any of the input sequences are shorter than the others. + /// + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + /// The type of the elements of . + /// The fourth sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond,TThird,TFourth)> + EquiZip(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth + ) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create); + +} diff --git a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs index 085a95d1..76381788 100644 --- a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs +++ b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/Fold.g.cs @@ -1,436 +1,735 @@ namespace SuperLinq.Async; + #nullable enable + public static partial class AsyncSuperEnumerable { - /// - /// Returns the result of applying a function to a sequence of 1 element. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 1 element. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(1).ToListAsync().ConfigureAwait(false); - return folder(elements[0]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 2 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 2 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(2).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 3 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 3 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(3).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 4 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 4 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(4).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 5 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 5 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(5).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 6 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 6 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(6).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 7 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 7 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(7).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 8 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 8 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(8).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 9 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 9 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(9).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 10 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 10 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(10).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 11 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 11 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(11).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 12 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 12 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(12).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 13 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 13 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(13).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 14 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 14 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(14).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12], elements[13]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 15 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 15 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(15).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12], elements[13], elements[14]); - } - } - - /// - /// Returns the result of applying a function to a sequence of 16 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// Type of element in the source sequence - /// Type of the result - /// The sequence of items to fold. - /// Function to apply to the elements in the sequence. - /// The folded value returned by . - /// or is null. - /// - /// does not contain exactly 16 elements. - /// - public static global::System.Threading.Tasks.ValueTask Fold(this global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - return Core(source, folder); - static async global::System.Threading.Tasks.ValueTask Core(global::System.Collections.Generic.IAsyncEnumerable source, global::System.Func folder) - { - var elements = await source.AssertCount(16).ToListAsync().ConfigureAwait(false); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12], elements[13], elements[14], elements[15]); - } - } -} \ No newline at end of file + /// + /// Returns the result of applying a function to a sequence of 1 element. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 1 element. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(1).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 2 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 2 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(2).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 3 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 3 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(3).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 4 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 4 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(4).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 5 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 5 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(5).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 6 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 6 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(6).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 7 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 7 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(7).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 8 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 8 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(8).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 9 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 9 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(9).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 10 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 10 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(10).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 11 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 11 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(11).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 12 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 12 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(12).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 13 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 13 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(13).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 14 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 14 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(14).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12], + elements[13] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 15 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 15 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(15).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12], + elements[13], + elements[14] + ); + } + } + + /// + /// Returns the result of applying a function to a sequence of 16 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// Type of element in the source sequence + /// Type of the result + /// The sequence of items to fold. + /// Function to apply to the elements in the sequence. + /// The folded value returned by . + /// or is null. + /// + /// does not contain exactly 16 elements. + /// + public static global::System.Threading.Tasks.ValueTask Fold( + this global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + return Core(source, folder); + + static async global::System.Threading.Tasks.ValueTask Core( + global::System.Collections.Generic.IAsyncEnumerable source, + global::System.Func folder + ) + { + var elements = await source.AssertCount(16).ToListAsync().ConfigureAwait(false); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12], + elements[13], + elements[14], + elements[15] + ); + } + } + +} diff --git a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipLongest.g.cs b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipLongest.g.cs index 31038bfc..76cece33 100644 --- a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipLongest.g.cs +++ b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipLongest.g.cs @@ -1,215 +1,322 @@ namespace SuperLinq.Async; + #nullable enable + public static partial class AsyncSuperEnumerable { - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f1 = true; - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f2 = true; - while (true) - { - var v1 = (f1 && (f1 = await e1.MoveNextAsync())) ? e1.Current : default(T1); - var v2 = (f2 && (f2 = await e2.MoveNextAsync())) ? e2.Current : default(T2); - if (!f1 && !f2) - yield break; - yield return resultSelector(v1, v2); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(T1? , T2? )> ZipLongest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second) => ZipLongest(first, second, global::System.ValueTuple.Create); - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f1 = true; - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f2 = true; - await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f3 = true; - while (true) - { - var v1 = (f1 && (f1 = await e1.MoveNextAsync())) ? e1.Current : default(T1); - var v2 = (f2 && (f2 = await e2.MoveNextAsync())) ? e2.Current : default(T2); - var v3 = (f3 && (f3 = await e3.MoveNextAsync())) ? e3.Current : default(T3); - if (!f1 && !f2 && !f3) - yield break; - yield return resultSelector(v1, v2, v3); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(T1? , T2? , T3? )> ZipLongest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third) => ZipLongest(first, second, third, global::System.ValueTuple.Create); - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - /// The type of the elements of . - /// The fourth sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f1 = true; - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f2 = true; - await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f3 = true; - await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - var f4 = true; - while (true) - { - var v1 = (f1 && (f1 = await e1.MoveNextAsync())) ? e1.Current : default(T1); - var v2 = (f2 && (f2 = await e2.MoveNextAsync())) ? e2.Current : default(T2); - var v3 = (f3 && (f3 = await e3.MoveNextAsync())) ? e3.Current : default(T3); - var v4 = (f4 && (f4 = await e4.MoveNextAsync())) ? e4.Current : default(T4); - if (!f1 && !f2 && !f3 && !f4) - yield break; - yield return resultSelector(v1, v2, v3, v4); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - /// The type of the elements of . - /// The fourth sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(T1? , T2? , T3? , T4? )> ZipLongest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth) => ZipLongest(first, second, third, fourth, global::System.ValueTuple.Create); -} \ No newline at end of file + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f1 = true; + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f2 = true; + + while (true) + { + var v1 = (f1 && (f1 = await e1.MoveNextAsync())) + ? e1.Current : default(T1); + var v2 = (f2 && (f2 = await e2.MoveNextAsync())) + ? e2.Current : default(T2); + + if (!f1 && !f2) + yield break; + + yield return resultSelector( + v1, + v2 + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(T1?,T2?)> + ZipLongest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second + ) => ZipLongest(first, second, global::System.ValueTuple.Create); + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f1 = true; + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f2 = true; + await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f3 = true; + + while (true) + { + var v1 = (f1 && (f1 = await e1.MoveNextAsync())) + ? e1.Current : default(T1); + var v2 = (f2 && (f2 = await e2.MoveNextAsync())) + ? e2.Current : default(T2); + var v3 = (f3 && (f3 = await e3.MoveNextAsync())) + ? e3.Current : default(T3); + + if (!f1 && !f2 && !f3) + yield break; + + yield return resultSelector( + v1, + v2, + v3 + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(T1?,T2?,T3?)> + ZipLongest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third + ) => ZipLongest(first, second, third, global::System.ValueTuple.Create); + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + /// The type of the elements of . + /// The fourth sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable ZipLongest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f1 = true; + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f2 = true; + await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f3 = true; + await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + var f4 = true; + + while (true) + { + var v1 = (f1 && (f1 = await e1.MoveNextAsync())) + ? e1.Current : default(T1); + var v2 = (f2 && (f2 = await e2.MoveNextAsync())) + ? e2.Current : default(T2); + var v3 = (f3 && (f3 = await e3.MoveNextAsync())) + ? e3.Current : default(T3); + var v4 = (f4 && (f4 = await e4.MoveNextAsync())) + ? e4.Current : default(T4); + + if (!f1 && !f2 && !f3 && !f4) + yield break; + + yield return resultSelector( + v1, + v2, + v3, + v4 + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + /// The type of the elements of . + /// The fourth sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(T1?,T2?,T3?,T4?)> + ZipLongest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth + ) => ZipLongest(first, second, third, fourth, global::System.ValueTuple.Create); + +} diff --git a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipShortest.g.cs b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipShortest.g.cs index f2566607..6b57f709 100644 --- a/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipShortest.g.cs +++ b/Source/SuperLinq.Async/Generated/SuperLinq.Async.Generator/SuperLinq.Async.Generator.Generator/ZipShortest.g.cs @@ -1,185 +1,289 @@ namespace SuperLinq.Async; + #nullable enable + public static partial class AsyncSuperEnumerable { - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) - { - yield return resultSelector(e1.Current, e2.Current); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond)> ZipShortest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second) => ZipShortest(first, second, global::System.ValueTuple.Create); - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - while (await e1.MoveNextAsync() && await e2.MoveNextAsync() && await e3.MoveNextAsync()) - { - yield return resultSelector(e1.Current, e2.Current, e3.Current); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond, TThird)> ZipShortest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third) => ZipShortest(first, second, third, global::System.ValueTuple.Create); - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// A projection function that combines - /// elements from all of the sequences. - /// A sequence of elements returned by . - /// - /// This method uses deferred execution and streams its results. - /// - /// or any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - /// The type of the elements of . - /// The fourth sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, resultSelector); - static async global::System.Collections.Generic.IAsyncEnumerable Core(global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth, global::System.Func resultSelector, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); - while (await e1.MoveNextAsync() && await e2.MoveNextAsync() && await e3.MoveNextAsync() && await e4.MoveNextAsync()) - { - yield return resultSelector(e1.Current, e2.Current, e3.Current, e4.Current); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th - /// element from each of the argument sequences. The resulting sequence - /// will always be as long as the longest of input sequences where the - /// default value of each of the shorter sequence element types is used - /// for padding. - /// - /// A sequence of - /// - /// containing corresponding elements from each of the sequences. - /// - /// This method uses deferred execution and streams its results. - /// - /// Any of the input sequences is null. - /// The type of the elements of . - /// The first sequence of elements. - /// The type of the elements of . - /// The second sequence of elements. - /// The type of the elements of . - /// The third sequence of elements. - /// The type of the elements of . - /// The fourth sequence of elements. - public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst, TSecond, TThird, TFourth)> ZipShortest(this global::System.Collections.Generic.IAsyncEnumerable first, global::System.Collections.Generic.IAsyncEnumerable second, global::System.Collections.Generic.IAsyncEnumerable third, global::System.Collections.Generic.IAsyncEnumerable fourth) => ZipShortest(first, second, third, fourth, global::System.ValueTuple.Create); -} \ No newline at end of file + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + + while ( + await e1.MoveNextAsync() + && await e2.MoveNextAsync() + ) + { + yield return resultSelector( + e1.Current, + e2.Current + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond)> + ZipShortest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second + ) => ZipShortest(first, second, global::System.ValueTuple.Create); + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + + while ( + await e1.MoveNextAsync() + && await e2.MoveNextAsync() + && await e3.MoveNextAsync() + ) + { + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond,TThird)> + ZipShortest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third + ) => ZipShortest(first, second, third, global::System.ValueTuple.Create); + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. + /// A projection function that combines + /// elements from all of the sequences. + /// A sequence of elements returned by . + /// + /// This method uses deferred execution and streams its results. + /// + /// or any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + /// The type of the elements of . + /// The fourth sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable ZipShortest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static async global::System.Collections.Generic.IAsyncEnumerable Core( + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth, + global::System.Func resultSelector, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + await using var e1 = first.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e2 = second.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e3 = third.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + await using var e4 = fourth.ConfigureAwait(false).WithCancellation(cancellationToken).GetAsyncEnumerator(); + + while ( + await e1.MoveNextAsync() + && await e2.MoveNextAsync() + && await e3.MoveNextAsync() + && await e4.MoveNextAsync() + ) + { + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current, + e4.Current + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th + /// element from each of the argument sequences. The resulting sequence + /// will always be as long as the longest of input sequences where the + /// default value of each of the shorter sequence element types is used + /// for padding. + /// + /// A sequence of + /// + /// containing corresponding elements from each of the sequences. + /// + /// This method uses deferred execution and streams its results. + /// + /// Any of the input sequences is null. + /// The type of the elements of . + /// The first sequence of elements. + /// The type of the elements of . + /// The second sequence of elements. + /// The type of the elements of . + /// The third sequence of elements. + /// The type of the elements of . + /// The fourth sequence of elements. + public static global::System.Collections.Generic.IAsyncEnumerable<(TFirst,TSecond,TThird,TFourth)> + ZipShortest(this + global::System.Collections.Generic.IAsyncEnumerable first, + global::System.Collections.Generic.IAsyncEnumerable second, + global::System.Collections.Generic.IAsyncEnumerable third, + global::System.Collections.Generic.IAsyncEnumerable fourth + ) => ZipShortest(first, second, third, fourth, global::System.ValueTuple.Create); + +} diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Aggregate.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Aggregate.g.cs index 337370af..76dc0525 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Aggregate.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Aggregate.g.cs @@ -1,593 +1,770 @@ namespace SuperLinq; + #nullable enable + public static partial class SuperEnumerable { - /// - /// Applies two accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - } - - return resultSelector(seed1, seed2); - } - - /// - /// Applies two accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - public static (TAccumulate1, TAccumulate2) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, global::System.ValueTuple.Create); - /// - /// Applies three accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(accumulator3); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - seed3 = accumulator3(seed3, item); - } - - return resultSelector(seed1, seed2, seed3); - } - - /// - /// Applies three accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - public static (TAccumulate1, TAccumulate2, TAccumulate3) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, global::System.ValueTuple.Create); - /// - /// Applies four accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(accumulator3); - ArgumentNullException.ThrowIfNull(accumulator4); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - seed3 = accumulator3(seed3, item); - seed4 = accumulator4(seed4, item); - } - - return resultSelector(seed1, seed2, seed3, seed4); - } - - /// - /// Applies four accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - public static (TAccumulate1, TAccumulate2, TAccumulate3, TAccumulate4) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, global::System.ValueTuple.Create); - /// - /// Applies five accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(accumulator3); - ArgumentNullException.ThrowIfNull(accumulator4); - ArgumentNullException.ThrowIfNull(accumulator5); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - seed3 = accumulator3(seed3, item); - seed4 = accumulator4(seed4, item); - seed5 = accumulator5(seed5, item); - } - - return resultSelector(seed1, seed2, seed3, seed4, seed5); - } - - /// - /// Applies five accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - public static (TAccumulate1, TAccumulate2, TAccumulate3, TAccumulate4, TAccumulate5) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, global::System.ValueTuple.Create); - /// - /// Applies six accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - /// The type of the sixth accumulator value. - /// The seed value for the sixth accumulator. - /// The sixth accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, TAccumulate6 seed6, global::System.Func accumulator6, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(accumulator3); - ArgumentNullException.ThrowIfNull(accumulator4); - ArgumentNullException.ThrowIfNull(accumulator5); - ArgumentNullException.ThrowIfNull(accumulator6); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - seed3 = accumulator3(seed3, item); - seed4 = accumulator4(seed4, item); - seed5 = accumulator5(seed5, item); - seed6 = accumulator6(seed6, item); - } - - return resultSelector(seed1, seed2, seed3, seed4, seed5, seed6); - } - - /// - /// Applies six accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - /// The type of the sixth accumulator value. - /// The seed value for the sixth accumulator. - /// The sixth accumulator. - public static (TAccumulate1, TAccumulate2, TAccumulate3, TAccumulate4, TAccumulate5, TAccumulate6) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, TAccumulate6 seed6, global::System.Func accumulator6) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, seed6, accumulator6, global::System.ValueTuple.Create); - /// - /// Applies seven accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - /// The type of the sixth accumulator value. - /// The seed value for the sixth accumulator. - /// The sixth accumulator. - /// The type of the seventh accumulator value. - /// The seed value for the seventh accumulator. - /// The seventh accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, TAccumulate6 seed6, global::System.Func accumulator6, TAccumulate7 seed7, global::System.Func accumulator7, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(accumulator3); - ArgumentNullException.ThrowIfNull(accumulator4); - ArgumentNullException.ThrowIfNull(accumulator5); - ArgumentNullException.ThrowIfNull(accumulator6); - ArgumentNullException.ThrowIfNull(accumulator7); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - seed3 = accumulator3(seed3, item); - seed4 = accumulator4(seed4, item); - seed5 = accumulator5(seed5, item); - seed6 = accumulator6(seed6, item); - seed7 = accumulator7(seed7, item); - } - - return resultSelector(seed1, seed2, seed3, seed4, seed5, seed6, seed7); - } - - /// - /// Applies seven accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - /// The type of the sixth accumulator value. - /// The seed value for the sixth accumulator. - /// The sixth accumulator. - /// The type of the seventh accumulator value. - /// The seed value for the seventh accumulator. - /// The seventh accumulator. - public static (TAccumulate1, TAccumulate2, TAccumulate3, TAccumulate4, TAccumulate5, TAccumulate6, TAccumulate7) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, TAccumulate6 seed6, global::System.Func accumulator6, TAccumulate7 seed7, global::System.Func accumulator7) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, seed6, accumulator6, seed7, accumulator7, global::System.ValueTuple.Create); - /// - /// Applies eight accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The type of the accumulated result. - /// The source sequence - /// - /// A function that projects a single result given the result of each accumulator. - /// - /// The value returned by . - /// - /// This operator executes immediately. - /// - /// - /// , or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - /// The type of the sixth accumulator value. - /// The seed value for the sixth accumulator. - /// The sixth accumulator. - /// The type of the seventh accumulator value. - /// The seed value for the seventh accumulator. - /// The seventh accumulator. - /// The type of the eighth accumulator value. - /// The seed value for the eighth accumulator. - /// The eighth accumulator. - public static TResult Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, TAccumulate6 seed6, global::System.Func accumulator6, TAccumulate7 seed7, global::System.Func accumulator7, TAccumulate8 seed8, global::System.Func accumulator8, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(accumulator1); - ArgumentNullException.ThrowIfNull(accumulator2); - ArgumentNullException.ThrowIfNull(accumulator3); - ArgumentNullException.ThrowIfNull(accumulator4); - ArgumentNullException.ThrowIfNull(accumulator5); - ArgumentNullException.ThrowIfNull(accumulator6); - ArgumentNullException.ThrowIfNull(accumulator7); - ArgumentNullException.ThrowIfNull(accumulator8); - ArgumentNullException.ThrowIfNull(resultSelector); - foreach (var item in source) - { - seed1 = accumulator1(seed1, item); - seed2 = accumulator2(seed2, item); - seed3 = accumulator3(seed3, item); - seed4 = accumulator4(seed4, item); - seed5 = accumulator5(seed5, item); - seed6 = accumulator6(seed6, item); - seed7 = accumulator7(seed7, item); - seed8 = accumulator8(seed8, item); - } - - return resultSelector(seed1, seed2, seed3, seed4, seed5, seed6, seed7, seed8); - } - - /// - /// Applies eight accumulators sequentially in a single pass over a - /// sequence. - /// - /// The type of elements in . - /// The source sequence - /// A - /// - /// containing the result of each accumulator. - /// - /// This operator executes immediately. - /// - /// - /// or any of the accumulator functions is null. - /// - /// The type of the first accumulator value. - /// The seed value for the first accumulator. - /// The first accumulator. - /// The type of the second accumulator value. - /// The seed value for the second accumulator. - /// The second accumulator. - /// The type of the third accumulator value. - /// The seed value for the third accumulator. - /// The third accumulator. - /// The type of the fourth accumulator value. - /// The seed value for the fourth accumulator. - /// The fourth accumulator. - /// The type of the fifth accumulator value. - /// The seed value for the fifth accumulator. - /// The fifth accumulator. - /// The type of the sixth accumulator value. - /// The seed value for the sixth accumulator. - /// The sixth accumulator. - /// The type of the seventh accumulator value. - /// The seed value for the seventh accumulator. - /// The seventh accumulator. - /// The type of the eighth accumulator value. - /// The seed value for the eighth accumulator. - /// The eighth accumulator. - public static (TAccumulate1, TAccumulate2, TAccumulate3, TAccumulate4, TAccumulate5, TAccumulate6, TAccumulate7, TAccumulate8) Aggregate(this global::System.Collections.Generic.IEnumerable source, TAccumulate1 seed1, global::System.Func accumulator1, TAccumulate2 seed2, global::System.Func accumulator2, TAccumulate3 seed3, global::System.Func accumulator3, TAccumulate4 seed4, global::System.Func accumulator4, TAccumulate5 seed5, global::System.Func accumulator5, TAccumulate6 seed6, global::System.Func accumulator6, TAccumulate7 seed7, global::System.Func accumulator7, TAccumulate8 seed8, global::System.Func accumulator8) => Aggregate(source, seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, seed6, accumulator6, seed7, accumulator7, seed8, accumulator8, global::System.ValueTuple.Create); -} \ No newline at end of file + /// + /// Applies two accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + } + + return resultSelector( + seed1, + seed2 + ); + } + + /// + /// Applies two accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + public static (TAccumulate1,TAccumulate2) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, global::System.ValueTuple.Create); + + /// + /// Applies three accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + ArgumentNullException.ThrowIfNull(accumulator3); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + seed3 = accumulator3(seed3, item); + } + + return resultSelector( + seed1, + seed2, + seed3 + ); + } + + /// + /// Applies three accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + public static (TAccumulate1,TAccumulate2,TAccumulate3) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, global::System.ValueTuple.Create); + + /// + /// Applies four accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + ArgumentNullException.ThrowIfNull(accumulator3); + ArgumentNullException.ThrowIfNull(accumulator4); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + seed3 = accumulator3(seed3, item); + seed4 = accumulator4(seed4, item); + } + + return resultSelector( + seed1, + seed2, + seed3, + seed4 + ); + } + + /// + /// Applies four accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + public static (TAccumulate1,TAccumulate2,TAccumulate3,TAccumulate4) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, global::System.ValueTuple.Create); + + /// + /// Applies five accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + ArgumentNullException.ThrowIfNull(accumulator3); + ArgumentNullException.ThrowIfNull(accumulator4); + ArgumentNullException.ThrowIfNull(accumulator5); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + seed3 = accumulator3(seed3, item); + seed4 = accumulator4(seed4, item); + seed5 = accumulator5(seed5, item); + } + + return resultSelector( + seed1, + seed2, + seed3, + seed4, + seed5 + ); + } + + /// + /// Applies five accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + public static (TAccumulate1,TAccumulate2,TAccumulate3,TAccumulate4,TAccumulate5) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, global::System.ValueTuple.Create); + + /// + /// Applies six accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + /// The type of the sixth accumulator value. + /// The seed value for the sixth accumulator. + /// The sixth accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + TAccumulate6 seed6, global::System.Func accumulator6, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + ArgumentNullException.ThrowIfNull(accumulator3); + ArgumentNullException.ThrowIfNull(accumulator4); + ArgumentNullException.ThrowIfNull(accumulator5); + ArgumentNullException.ThrowIfNull(accumulator6); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + seed3 = accumulator3(seed3, item); + seed4 = accumulator4(seed4, item); + seed5 = accumulator5(seed5, item); + seed6 = accumulator6(seed6, item); + } + + return resultSelector( + seed1, + seed2, + seed3, + seed4, + seed5, + seed6 + ); + } + + /// + /// Applies six accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + /// The type of the sixth accumulator value. + /// The seed value for the sixth accumulator. + /// The sixth accumulator. + public static (TAccumulate1,TAccumulate2,TAccumulate3,TAccumulate4,TAccumulate5,TAccumulate6) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + TAccumulate6 seed6, global::System.Func accumulator6 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, seed6, accumulator6, global::System.ValueTuple.Create); + + /// + /// Applies seven accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + /// The type of the sixth accumulator value. + /// The seed value for the sixth accumulator. + /// The sixth accumulator. + /// The type of the seventh accumulator value. + /// The seed value for the seventh accumulator. + /// The seventh accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + TAccumulate6 seed6, global::System.Func accumulator6, + TAccumulate7 seed7, global::System.Func accumulator7, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + ArgumentNullException.ThrowIfNull(accumulator3); + ArgumentNullException.ThrowIfNull(accumulator4); + ArgumentNullException.ThrowIfNull(accumulator5); + ArgumentNullException.ThrowIfNull(accumulator6); + ArgumentNullException.ThrowIfNull(accumulator7); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + seed3 = accumulator3(seed3, item); + seed4 = accumulator4(seed4, item); + seed5 = accumulator5(seed5, item); + seed6 = accumulator6(seed6, item); + seed7 = accumulator7(seed7, item); + } + + return resultSelector( + seed1, + seed2, + seed3, + seed4, + seed5, + seed6, + seed7 + ); + } + + /// + /// Applies seven accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + /// The type of the sixth accumulator value. + /// The seed value for the sixth accumulator. + /// The sixth accumulator. + /// The type of the seventh accumulator value. + /// The seed value for the seventh accumulator. + /// The seventh accumulator. + public static (TAccumulate1,TAccumulate2,TAccumulate3,TAccumulate4,TAccumulate5,TAccumulate6,TAccumulate7) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + TAccumulate6 seed6, global::System.Func accumulator6, + TAccumulate7 seed7, global::System.Func accumulator7 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, seed6, accumulator6, seed7, accumulator7, global::System.ValueTuple.Create); + + /// + /// Applies eight accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The type of the accumulated result. + /// The source sequence + /// + /// A function that projects a single result given the result of each accumulator. + /// + /// The value returned by . + /// + /// This operator executes immediately. + /// + /// + /// , or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + /// The type of the sixth accumulator value. + /// The seed value for the sixth accumulator. + /// The sixth accumulator. + /// The type of the seventh accumulator value. + /// The seed value for the seventh accumulator. + /// The seventh accumulator. + /// The type of the eighth accumulator value. + /// The seed value for the eighth accumulator. + /// The eighth accumulator. + public static TResult Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + TAccumulate6 seed6, global::System.Func accumulator6, + TAccumulate7 seed7, global::System.Func accumulator7, + TAccumulate8 seed8, global::System.Func accumulator8, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(source); + + ArgumentNullException.ThrowIfNull(accumulator1); + ArgumentNullException.ThrowIfNull(accumulator2); + ArgumentNullException.ThrowIfNull(accumulator3); + ArgumentNullException.ThrowIfNull(accumulator4); + ArgumentNullException.ThrowIfNull(accumulator5); + ArgumentNullException.ThrowIfNull(accumulator6); + ArgumentNullException.ThrowIfNull(accumulator7); + ArgumentNullException.ThrowIfNull(accumulator8); + + ArgumentNullException.ThrowIfNull(resultSelector); + + foreach (var item in source) + { + seed1 = accumulator1(seed1, item); + seed2 = accumulator2(seed2, item); + seed3 = accumulator3(seed3, item); + seed4 = accumulator4(seed4, item); + seed5 = accumulator5(seed5, item); + seed6 = accumulator6(seed6, item); + seed7 = accumulator7(seed7, item); + seed8 = accumulator8(seed8, item); + } + + return resultSelector( + seed1, + seed2, + seed3, + seed4, + seed5, + seed6, + seed7, + seed8 + ); + } + + /// + /// Applies eight accumulators sequentially in a single pass over a + /// sequence. + /// + /// The type of elements in . + /// The source sequence + /// A + /// + /// containing the result of each accumulator. + /// + /// This operator executes immediately. + /// + /// + /// or any of the accumulator functions is null. + /// + /// The type of the first accumulator value. + /// The seed value for the first accumulator. + /// The first accumulator. + /// The type of the second accumulator value. + /// The seed value for the second accumulator. + /// The second accumulator. + /// The type of the third accumulator value. + /// The seed value for the third accumulator. + /// The third accumulator. + /// The type of the fourth accumulator value. + /// The seed value for the fourth accumulator. + /// The fourth accumulator. + /// The type of the fifth accumulator value. + /// The seed value for the fifth accumulator. + /// The fifth accumulator. + /// The type of the sixth accumulator value. + /// The seed value for the sixth accumulator. + /// The sixth accumulator. + /// The type of the seventh accumulator value. + /// The seed value for the seventh accumulator. + /// The seventh accumulator. + /// The type of the eighth accumulator value. + /// The seed value for the eighth accumulator. + /// The eighth accumulator. + public static (TAccumulate1,TAccumulate2,TAccumulate3,TAccumulate4,TAccumulate5,TAccumulate6,TAccumulate7,TAccumulate8) Aggregate( + this global::System.Collections.Generic.IEnumerable source, + TAccumulate1 seed1, global::System.Func accumulator1, + TAccumulate2 seed2, global::System.Func accumulator2, + TAccumulate3 seed3, global::System.Func accumulator3, + TAccumulate4 seed4, global::System.Func accumulator4, + TAccumulate5 seed5, global::System.Func accumulator5, + TAccumulate6 seed6, global::System.Func accumulator6, + TAccumulate7 seed7, global::System.Func accumulator7, + TAccumulate8 seed8, global::System.Func accumulator8 + ) => Aggregate(source,seed1, accumulator1, seed2, accumulator2, seed3, accumulator3, seed4, accumulator4, seed5, accumulator5, seed6, accumulator6, seed7, accumulator7, seed8, accumulator8, global::System.ValueTuple.Create); + +} diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Cartesian.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Cartesian.g.cs index 09881a91..8533a0d9 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Cartesian.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Cartesian.g.cs @@ -1,922 +1,1204 @@ namespace SuperLinq; + #nullable enable + public static partial class SuperEnumerable { - /// - /// Returns the Cartesian product of two sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - yield return resultSelector(item1, item2); - } - } - - /// - /// Returns the Cartesian product of two sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second) => Cartesian(first, second, global::System.ValueTuple.Create); - /// - /// Returns the Cartesian product of three sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - using var thirdMemo = third.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - foreach (var item3 in thirdMemo) - yield return resultSelector(item1, item2, item3); - } - } - - /// - /// Returns the Cartesian product of three sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2, T3)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third) => Cartesian(first, second, third, global::System.ValueTuple.Create); - /// - /// Returns the Cartesian product of four sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - using var thirdMemo = third.Memoize(); - using var fourthMemo = fourth.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - foreach (var item3 in thirdMemo) - foreach (var item4 in fourthMemo) - yield return resultSelector(item1, item2, item3, item4); - } - } - - /// - /// Returns the Cartesian product of four sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth) => Cartesian(first, second, third, fourth, global::System.ValueTuple.Create); - /// - /// Returns the Cartesian product of five sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(fifth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, fifth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - using var thirdMemo = third.Memoize(); - using var fourthMemo = fourth.Memoize(); - using var fifthMemo = fifth.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - foreach (var item3 in thirdMemo) - foreach (var item4 in fourthMemo) - foreach (var item5 in fifthMemo) - yield return resultSelector(item1, item2, item3, item4, item5); - } - } - - /// - /// Returns the Cartesian product of five sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth) => Cartesian(first, second, third, fourth, fifth, global::System.ValueTuple.Create); - /// - /// Returns the Cartesian product of six sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The sixth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(fifth); - ArgumentNullException.ThrowIfNull(sixth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, fifth, sixth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - using var thirdMemo = third.Memoize(); - using var fourthMemo = fourth.Memoize(); - using var fifthMemo = fifth.Memoize(); - using var sixthMemo = sixth.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - foreach (var item3 in thirdMemo) - foreach (var item4 in fourthMemo) - foreach (var item5 in fifthMemo) - foreach (var item6 in sixthMemo) - yield return resultSelector(item1, item2, item3, item4, item5, item6); - } - } - - /// - /// Returns the Cartesian product of six sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The sixth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth) => Cartesian(first, second, third, fourth, fifth, sixth, global::System.ValueTuple.Create); - /// - /// Returns the Cartesian product of seven sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The sixth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The seventh sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Collections.Generic.IEnumerable seventh, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(fifth); - ArgumentNullException.ThrowIfNull(sixth); - ArgumentNullException.ThrowIfNull(seventh); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, fifth, sixth, seventh, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Collections.Generic.IEnumerable seventh, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - using var thirdMemo = third.Memoize(); - using var fourthMemo = fourth.Memoize(); - using var fifthMemo = fifth.Memoize(); - using var sixthMemo = sixth.Memoize(); - using var seventhMemo = seventh.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - foreach (var item3 in thirdMemo) - foreach (var item4 in fourthMemo) - foreach (var item5 in fifthMemo) - foreach (var item6 in sixthMemo) - foreach (var item7 in seventhMemo) - yield return resultSelector(item1, item2, item3, item4, item5, item6, item7); - } - } - - /// - /// Returns the Cartesian product of seven sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The sixth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The seventh sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Collections.Generic.IEnumerable seventh) => Cartesian(first, second, third, fourth, fifth, sixth, seventh, global::System.ValueTuple.Create); - /// - /// Returns the Cartesian product of eight sequences by enumerating all possible combinations of one item from - /// each sequence, and applying a user-defined projection to the items in a given combination. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated - /// over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The sixth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The seventh sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The eighth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Collections.Generic.IEnumerable seventh, global::System.Collections.Generic.IEnumerable eighth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(fifth); - ArgumentNullException.ThrowIfNull(sixth); - ArgumentNullException.ThrowIfNull(seventh); - ArgumentNullException.ThrowIfNull(eighth); - ArgumentNullException.ThrowIfNull(resultSelector); - return Core(first, second, third, fourth, fifth, sixth, seventh, eighth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Collections.Generic.IEnumerable seventh, global::System.Collections.Generic.IEnumerable eighth, global::System.Func resultSelector) - { - using var firstMemo = first.Memoize(); - using var secondMemo = second.Memoize(); - using var thirdMemo = third.Memoize(); - using var fourthMemo = fourth.Memoize(); - using var fifthMemo = fifth.Memoize(); - using var sixthMemo = sixth.Memoize(); - using var seventhMemo = seventh.Memoize(); - using var eighthMemo = eighth.Memoize(); - foreach (var item1 in firstMemo) - foreach (var item2 in secondMemo) - foreach (var item3 in thirdMemo) - foreach (var item4 in fourthMemo) - foreach (var item5 in fifthMemo) - foreach (var item6 in sixthMemo) - foreach (var item7 in seventhMemo) - foreach (var item8 in eighthMemo) - yield return resultSelector(item1, item2, item3, item4, item5, item6, item7, item8); - } - } - - /// - /// Returns the Cartesian product of eight sequences by enumerating all possible combinations of one item from - /// each sequence. - /// - /// - /// A sequence of containing elements from each of the - /// sequences. - /// - /// - /// - /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when - /// iterated over. The cache is then re-used for any subsequent iterations. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fifth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The sixth sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The seventh sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The eighth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)> Cartesian(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Collections.Generic.IEnumerable fifth, global::System.Collections.Generic.IEnumerable sixth, global::System.Collections.Generic.IEnumerable seventh, global::System.Collections.Generic.IEnumerable eighth) => Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth, global::System.ValueTuple.Create); -} \ No newline at end of file + /// + /// Returns the Cartesian product of two sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + { + yield return resultSelector( + item1, + item2 + ); + } + } + } + + /// + /// Returns the Cartesian product of two sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second + ) => Cartesian(first, second, global::System.ValueTuple.Create); + + /// + /// Returns the Cartesian product of three sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + using var thirdMemo = third.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + foreach (var item3 in thirdMemo) + { + yield return resultSelector( + item1, + item2, + item3 + ); + } + } + } + + /// + /// Returns the Cartesian product of three sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2,T3)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third + ) => Cartesian(first, second, third, global::System.ValueTuple.Create); + + /// + /// Returns the Cartesian product of four sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + using var thirdMemo = third.Memoize(); + using var fourthMemo = fourth.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + foreach (var item3 in thirdMemo) + foreach (var item4 in fourthMemo) + { + yield return resultSelector( + item1, + item2, + item3, + item4 + ); + } + } + } + + /// + /// Returns the Cartesian product of four sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2,T3,T4)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth + ) => Cartesian(first, second, third, fourth, global::System.ValueTuple.Create); + + /// + /// Returns the Cartesian product of five sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + ArgumentNullException.ThrowIfNull(fifth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + fifth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + using var thirdMemo = third.Memoize(); + using var fourthMemo = fourth.Memoize(); + using var fifthMemo = fifth.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + foreach (var item3 in thirdMemo) + foreach (var item4 in fourthMemo) + foreach (var item5 in fifthMemo) + { + yield return resultSelector( + item1, + item2, + item3, + item4, + item5 + ); + } + } + } + + /// + /// Returns the Cartesian product of five sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2,T3,T4,T5)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth + ) => Cartesian(first, second, third, fourth, fifth, global::System.ValueTuple.Create); + + /// + /// Returns the Cartesian product of six sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The sixth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + ArgumentNullException.ThrowIfNull(fifth); + ArgumentNullException.ThrowIfNull(sixth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + fifth, + sixth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + using var thirdMemo = third.Memoize(); + using var fourthMemo = fourth.Memoize(); + using var fifthMemo = fifth.Memoize(); + using var sixthMemo = sixth.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + foreach (var item3 in thirdMemo) + foreach (var item4 in fourthMemo) + foreach (var item5 in fifthMemo) + foreach (var item6 in sixthMemo) + { + yield return resultSelector( + item1, + item2, + item3, + item4, + item5, + item6 + ); + } + } + } + + /// + /// Returns the Cartesian product of six sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The sixth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2,T3,T4,T5,T6)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth + ) => Cartesian(first, second, third, fourth, fifth, sixth, global::System.ValueTuple.Create); + + /// + /// Returns the Cartesian product of seven sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The sixth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The seventh sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Collections.Generic.IEnumerable seventh, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + ArgumentNullException.ThrowIfNull(fifth); + ArgumentNullException.ThrowIfNull(sixth); + ArgumentNullException.ThrowIfNull(seventh); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Collections.Generic.IEnumerable seventh, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + using var thirdMemo = third.Memoize(); + using var fourthMemo = fourth.Memoize(); + using var fifthMemo = fifth.Memoize(); + using var sixthMemo = sixth.Memoize(); + using var seventhMemo = seventh.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + foreach (var item3 in thirdMemo) + foreach (var item4 in fourthMemo) + foreach (var item5 in fifthMemo) + foreach (var item6 in sixthMemo) + foreach (var item7 in seventhMemo) + { + yield return resultSelector( + item1, + item2, + item3, + item4, + item5, + item6, + item7 + ); + } + } + } + + /// + /// Returns the Cartesian product of seven sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The sixth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The seventh sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2,T3,T4,T5,T6,T7)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Collections.Generic.IEnumerable seventh + ) => Cartesian(first, second, third, fourth, fifth, sixth, seventh, global::System.ValueTuple.Create); + + /// + /// Returns the Cartesian product of eight sequences by enumerating all possible combinations of one item from + /// each sequence, and applying a user-defined projection to the items in a given combination. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences cached when iterated + /// over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The sixth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The seventh sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The eighth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Collections.Generic.IEnumerable seventh, + global::System.Collections.Generic.IEnumerable eighth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + ArgumentNullException.ThrowIfNull(fifth); + ArgumentNullException.ThrowIfNull(sixth); + ArgumentNullException.ThrowIfNull(seventh); + ArgumentNullException.ThrowIfNull(eighth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + return Core( + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + eighth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Collections.Generic.IEnumerable seventh, + global::System.Collections.Generic.IEnumerable eighth, + global::System.Func resultSelector) + { + using var firstMemo = first.Memoize(); + using var secondMemo = second.Memoize(); + using var thirdMemo = third.Memoize(); + using var fourthMemo = fourth.Memoize(); + using var fifthMemo = fifth.Memoize(); + using var sixthMemo = sixth.Memoize(); + using var seventhMemo = seventh.Memoize(); + using var eighthMemo = eighth.Memoize(); + + foreach (var item1 in firstMemo) + foreach (var item2 in secondMemo) + foreach (var item3 in thirdMemo) + foreach (var item4 in fourthMemo) + foreach (var item5 in fifthMemo) + foreach (var item6 in sixthMemo) + foreach (var item7 in seventhMemo) + foreach (var item8 in eighthMemo) + { + yield return resultSelector( + item1, + item2, + item3, + item4, + item5, + item6, + item7, + item8 + ); + } + } + } + + /// + /// Returns the Cartesian product of eight sequences by enumerating all possible combinations of one item from + /// each sequence. + /// + /// + /// A sequence of containing elements from each of the + /// sequences. + /// + /// + /// + /// The method returns items in the same order as a nested foreach loop, but all sequences are cached when + /// iterated over. The cache is then re-used for any subsequent iterations. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fifth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The sixth sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The seventh sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The eighth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1,T2,T3,T4,T5,T6,T7,T8)> + Cartesian(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Collections.Generic.IEnumerable fifth, + global::System.Collections.Generic.IEnumerable sixth, + global::System.Collections.Generic.IEnumerable seventh, + global::System.Collections.Generic.IEnumerable eighth + ) => Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth, global::System.ValueTuple.Create); + +} diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs index 8956a8ac..e7efecef 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/EquiZip.g.cs @@ -1,511 +1,691 @@ namespace SuperLinq; + #nullable enable + public static partial class SuperEnumerable { - /// - /// - /// Applies a specified function to the corresponding elements of second sequences, producing a sequence of the - /// results. - /// - /// - /// The resulting sequence has the same length as the input sequences. If the input sequences are of different - /// lengths, an exception is thrown. - /// - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// Any of the input sequences are shorter than the others. - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable EquiZip(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2) - { - return new EquiZipIterator(list1, list2, resultSelector); - } - - return Core(first, second, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - using var e2 = second.GetEnumerator(); - while (true) - { - if (!e1.MoveNext()) - { - if (e2.MoveNext()) - { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } - - yield break; - } - - if (!e2.MoveNext()) - ThrowHelper.ThrowInvalidOperationException("Second sequence too short."); - yield return resultSelector(e1.Current, e2.Current); - } - } - } - - /// - /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. - /// - /// - /// A sequence of - /// containing corresponding elements from each of the sequences. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// Any of the input sequences is null. - /// - /// - /// Any of the input sequences are shorter than the others. - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(TFirst, TSecond)> EquiZip(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second) => EquiZip(first, second, global::System.ValueTuple.Create); - private class EquiZipIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Func _resultSelector; - public EquiZipIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _resultSelector = resultSelector; - } - - public override int Count - { - get - { - var count = _list1.Count; - if (_list2.Count != count) - { - ThrowHelper.ThrowInvalidOperationException((count < _list2.Count ? "First" : "Second") + " sequence too short."); - } - - return count; - } - } - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(_list1[i], _list2[i]); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(_list1[index], _list2[index]); - } - } - - /// - /// - /// Applies a specified function to the corresponding elements of second sequences, producing a sequence of the - /// results. - /// - /// - /// The resulting sequence has the same length as the input sequences. If the input sequences are of different - /// lengths, an exception is thrown. - /// - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// Any of the input sequences are shorter than the others. - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable EquiZip(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2 && third is global::System.Collections.Generic.IList list3) - { - return new EquiZipIterator(list1, list2, list3, resultSelector); - } - - return Core(first, second, third, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - using var e2 = second.GetEnumerator(); - using var e3 = third.GetEnumerator(); - while (true) - { - if (!e1.MoveNext()) - { - if (e2.MoveNext() || e3.MoveNext()) - { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } - - yield break; - } - - if (!e2.MoveNext()) - ThrowHelper.ThrowInvalidOperationException("Second sequence too short."); - if (!e3.MoveNext()) - ThrowHelper.ThrowInvalidOperationException("Third sequence too short."); - yield return resultSelector(e1.Current, e2.Current, e3.Current); - } - } - } - - /// - /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. - /// - /// - /// A sequence of - /// containing corresponding elements from each of the sequences. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// Any of the input sequences is null. - /// - /// - /// Any of the input sequences are shorter than the others. - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(TFirst, TSecond, TThird)> EquiZip(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third) => EquiZip(first, second, third, global::System.ValueTuple.Create); - private class EquiZipIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Collections.Generic.IList _list3; - private readonly global::System.Func _resultSelector; - public EquiZipIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Collections.Generic.IList third, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _list3 = third; - _resultSelector = resultSelector; - } - - public override int Count - { - get - { - var count = _list1.Count; - if (_list2.Count != count) - { - ThrowHelper.ThrowInvalidOperationException((count < _list2.Count ? "First" : "Second") + " sequence too short."); - } - - if (_list3.Count != count) - { - ThrowHelper.ThrowInvalidOperationException((count < _list3.Count ? "First" : "Third") + " sequence too short."); - } - - return count; - } - } - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(_list1[i], _list2[i], _list3[i]); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(_list1[index], _list2[index], _list3[index]); - } - } - - /// - /// - /// Applies a specified function to the corresponding elements of second sequences, producing a sequence of the - /// results. - /// - /// - /// The resulting sequence has the same length as the input sequences. If the input sequences are of different - /// lengths, an exception is thrown. - /// - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// Any of the input sequences are shorter than the others. - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable EquiZip(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2 && third is global::System.Collections.Generic.IList list3 && fourth is global::System.Collections.Generic.IList list4) - { - return new EquiZipIterator(list1, list2, list3, list4, resultSelector); - } - - return Core(first, second, third, fourth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - using var e2 = second.GetEnumerator(); - using var e3 = third.GetEnumerator(); - using var e4 = fourth.GetEnumerator(); - while (true) - { - if (!e1.MoveNext()) - { - if (e2.MoveNext() || e3.MoveNext() || e4.MoveNext()) - { - ThrowHelper.ThrowInvalidOperationException("First sequence too short."); - } - - yield break; - } - - if (!e2.MoveNext()) - ThrowHelper.ThrowInvalidOperationException("Second sequence too short."); - if (!e3.MoveNext()) - ThrowHelper.ThrowInvalidOperationException("Third sequence too short."); - if (!e4.MoveNext()) - ThrowHelper.ThrowInvalidOperationException("Fourth sequence too short."); - yield return resultSelector(e1.Current, e2.Current, e3.Current, e4.Current); - } - } - } - - /// - /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. - /// - /// - /// A sequence of - /// containing corresponding elements from each of the sequences. - /// - /// - /// This method uses deferred execution and stream its results. - /// - /// - /// Any of the input sequences is null. - /// - /// - /// Any of the input sequences are shorter than the others. - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(TFirst, TSecond, TThird, TFourth)> EquiZip(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create); - private class EquiZipIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Collections.Generic.IList _list3; - private readonly global::System.Collections.Generic.IList _list4; - private readonly global::System.Func _resultSelector; - public EquiZipIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Collections.Generic.IList third, global::System.Collections.Generic.IList fourth, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _list3 = third; - _list4 = fourth; - _resultSelector = resultSelector; - } - - public override int Count - { - get - { - var count = _list1.Count; - if (_list2.Count != count) - { - ThrowHelper.ThrowInvalidOperationException((count < _list2.Count ? "First" : "Second") + " sequence too short."); - } - - if (_list3.Count != count) - { - ThrowHelper.ThrowInvalidOperationException((count < _list3.Count ? "First" : "Third") + " sequence too short."); - } - - if (_list4.Count != count) - { - ThrowHelper.ThrowInvalidOperationException((count < _list4.Count ? "First" : "Fourth") + " sequence too short."); - } - - return count; - } - } - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(_list1[i], _list2[i], _list3[i], _list4[i]); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(_list1[index], _list2[index], _list3[index], _list4[index]); - } - } -} \ No newline at end of file + /// + /// + /// Applies a specified function to the corresponding elements of second sequences, producing a sequence of the + /// results. + /// + /// + /// The resulting sequence has the same length as the input sequences. If the input sequences are of different + /// lengths, an exception is thrown. + /// + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// Any of the input sequences are shorter than the others. + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable EquiZip(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2) + { + return new EquiZipIterator( + list1, + list2, + resultSelector + ); + } + + return Core( + first, + second, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + using var e2 = second.GetEnumerator(); + + while (true) + { + if (!e1.MoveNext()) + { + if (e2.MoveNext() + ) + { + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } + + yield break; + } + + if (!e2.MoveNext()) + ThrowHelper.ThrowInvalidOperationException( + "Second sequence too short."); + + yield return resultSelector( + e1.Current, + e2.Current + ); + } + } + } + + /// + /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. + /// + /// + /// A sequence of + /// containing corresponding elements from each of the sequences. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// Any of the input sequences is null. + /// + /// + /// Any of the input sequences are shorter than the others. + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(TFirst,TSecond)> + EquiZip(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second + ) => EquiZip(first, second, global::System.ValueTuple.Create); + + private class EquiZipIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Func _resultSelector; + + public EquiZipIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _resultSelector = resultSelector; + } + + public override int Count + { + get + { + var count = _list1.Count; + + if (_list2.Count != count) + { + ThrowHelper.ThrowInvalidOperationException( + (count < _list2.Count ? "First" : "Second") + " sequence too short."); + } + + return count; + } + } + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + _list1[i], + _list2[i] + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + _list1[index], + _list2[index] + ); + } + } + + /// + /// + /// Applies a specified function to the corresponding elements of second sequences, producing a sequence of the + /// results. + /// + /// + /// The resulting sequence has the same length as the input sequences. If the input sequences are of different + /// lengths, an exception is thrown. + /// + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// Any of the input sequences are shorter than the others. + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable EquiZip(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2&& + third is global::System.Collections.Generic.IList list3) + { + return new EquiZipIterator( + list1, + list2, + list3, + resultSelector + ); + } + + return Core( + first, + second, + third, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + using var e2 = second.GetEnumerator(); + using var e3 = third.GetEnumerator(); + + while (true) + { + if (!e1.MoveNext()) + { + if (e2.MoveNext() + || e3.MoveNext() + ) + { + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } + + yield break; + } + + if (!e2.MoveNext()) + ThrowHelper.ThrowInvalidOperationException( + "Second sequence too short."); + if (!e3.MoveNext()) + ThrowHelper.ThrowInvalidOperationException( + "Third sequence too short."); + + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current + ); + } + } + } + + /// + /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. + /// + /// + /// A sequence of + /// containing corresponding elements from each of the sequences. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// Any of the input sequences is null. + /// + /// + /// Any of the input sequences are shorter than the others. + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(TFirst,TSecond,TThird)> + EquiZip(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third + ) => EquiZip(first, second, third, global::System.ValueTuple.Create); + + private class EquiZipIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Collections.Generic.IList _list3; + private readonly global::System.Func _resultSelector; + + public EquiZipIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Collections.Generic.IList third, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _list3 = third; + _resultSelector = resultSelector; + } + + public override int Count + { + get + { + var count = _list1.Count; + + if (_list2.Count != count) + { + ThrowHelper.ThrowInvalidOperationException( + (count < _list2.Count ? "First" : "Second") + " sequence too short."); + } + if (_list3.Count != count) + { + ThrowHelper.ThrowInvalidOperationException( + (count < _list3.Count ? "First" : "Third") + " sequence too short."); + } + + return count; + } + } + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + _list1[i], + _list2[i], + _list3[i] + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + _list1[index], + _list2[index], + _list3[index] + ); + } + } + + /// + /// + /// Applies a specified function to the corresponding elements of second sequences, producing a sequence of the + /// results. + /// + /// + /// The resulting sequence has the same length as the input sequences. If the input sequences are of different + /// lengths, an exception is thrown. + /// + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// Any of the input sequences are shorter than the others. + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable EquiZip(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2&& + third is global::System.Collections.Generic.IList list3&& + fourth is global::System.Collections.Generic.IList list4) + { + return new EquiZipIterator( + list1, + list2, + list3, + list4, + resultSelector + ); + } + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + using var e2 = second.GetEnumerator(); + using var e3 = third.GetEnumerator(); + using var e4 = fourth.GetEnumerator(); + + while (true) + { + if (!e1.MoveNext()) + { + if (e2.MoveNext() + || e3.MoveNext() + || e4.MoveNext() + ) + { + ThrowHelper.ThrowInvalidOperationException("First sequence too short."); + } + + yield break; + } + + if (!e2.MoveNext()) + ThrowHelper.ThrowInvalidOperationException( + "Second sequence too short."); + if (!e3.MoveNext()) + ThrowHelper.ThrowInvalidOperationException( + "Third sequence too short."); + if (!e4.MoveNext()) + ThrowHelper.ThrowInvalidOperationException( + "Fourth sequence too short."); + + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current, + e4.Current + ); + } + } + } + + /// + /// Joins the corresponding elements of second sequences, producing a sequence of tuples containing them. + /// + /// + /// A sequence of + /// containing corresponding elements from each of the sequences. + /// + /// + /// This method uses deferred execution and stream its results. + /// + /// + /// Any of the input sequences is null. + /// + /// + /// Any of the input sequences are shorter than the others. + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(TFirst,TSecond,TThird,TFourth)> + EquiZip(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth + ) => EquiZip(first, second, third, fourth, global::System.ValueTuple.Create); + + private class EquiZipIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Collections.Generic.IList _list3; + private readonly global::System.Collections.Generic.IList _list4; + private readonly global::System.Func _resultSelector; + + public EquiZipIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Collections.Generic.IList third, + global::System.Collections.Generic.IList fourth, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _list3 = third; + _list4 = fourth; + _resultSelector = resultSelector; + } + + public override int Count + { + get + { + var count = _list1.Count; + + if (_list2.Count != count) + { + ThrowHelper.ThrowInvalidOperationException( + (count < _list2.Count ? "First" : "Second") + " sequence too short."); + } + if (_list3.Count != count) + { + ThrowHelper.ThrowInvalidOperationException( + (count < _list3.Count ? "First" : "Third") + " sequence too short."); + } + if (_list4.Count != count) + { + ThrowHelper.ThrowInvalidOperationException( + (count < _list4.Count ? "First" : "Fourth") + " sequence too short."); + } + + return count; + } + } + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + _list1[i], + _list2[i], + _list3[i], + _list4[i] + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + _list1[index], + _list2[index], + _list3[index], + _list4[index] + ); + } + } + +} diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Fold.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Fold.g.cs index dbf6c998..16307211 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Fold.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/Fold.g.cs @@ -1,564 +1,799 @@ namespace SuperLinq; + #nullable enable + public static partial class SuperEnumerable { - /// - /// Returns the result of applying a function to a sequence of 1 element. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 1 element. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(1).ToList(); - return folder(elements[0]); - } - - /// - /// Returns the result of applying a function to a sequence of 2 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 2 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(2).ToList(); - return folder(elements[0], elements[1]); - } - - /// - /// Returns the result of applying a function to a sequence of 3 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 3 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(3).ToList(); - return folder(elements[0], elements[1], elements[2]); - } - - /// - /// Returns the result of applying a function to a sequence of 4 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 4 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(4).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3]); - } - - /// - /// Returns the result of applying a function to a sequence of 5 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 5 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(5).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4]); - } - - /// - /// Returns the result of applying a function to a sequence of 6 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 6 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(6).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]); - } - - /// - /// Returns the result of applying a function to a sequence of 7 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 7 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(7).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6]); - } - - /// - /// Returns the result of applying a function to a sequence of 8 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 8 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(8).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7]); - } - - /// - /// Returns the result of applying a function to a sequence of 9 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 9 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(9).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8]); - } - - /// - /// Returns the result of applying a function to a sequence of 10 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 10 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(10).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9]); - } - - /// - /// Returns the result of applying a function to a sequence of 11 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 11 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(11).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10]); - } - - /// - /// Returns the result of applying a function to a sequence of 12 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 12 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(12).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11]); - } - - /// - /// Returns the result of applying a function to a sequence of 13 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 13 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(13).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12]); - } - - /// - /// Returns the result of applying a function to a sequence of 14 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 14 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(14).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12], elements[13]); - } - - /// - /// Returns the result of applying a function to a sequence of 15 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 15 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(15).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12], elements[13], elements[14]); - } - - /// - /// Returns the result of applying a function to a sequence of 16 elements. - /// - /// - /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. - /// - /// - /// Type of element in the source sequence - /// - /// - /// Type of the result - /// - /// - /// The sequence of items to fold. - /// - /// - /// Function to apply to the elements in the sequence. - /// - /// - /// The folded value returned by . - /// - /// - /// or is . - /// - /// - /// does not contain exactly 16 elements. - /// - public static TResult Fold(this global::System.Collections.Generic.IEnumerable source, global::System.Func folder) - { - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(folder); - var elements = source.AssertCount(16).ToList(); - return folder(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5], elements[6], elements[7], elements[8], elements[9], elements[10], elements[11], elements[12], elements[13], elements[14], elements[15]); - } -} \ No newline at end of file + /// + /// Returns the result of applying a function to a sequence of 1 element. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 1 element. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(1).ToList(); + + return folder( + elements[0] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 2 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 2 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(2).ToList(); + + return folder( + elements[0], + elements[1] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 3 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 3 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(3).ToList(); + + return folder( + elements[0], + elements[1], + elements[2] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 4 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 4 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(4).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 5 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 5 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(5).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 6 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 6 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(6).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 7 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 7 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(7).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 8 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 8 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(8).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 9 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 9 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(9).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 10 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 10 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(10).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 11 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 11 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(11).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 12 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 12 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(12).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 13 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 13 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(13).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 14 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 14 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(14).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12], + elements[13] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 15 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 15 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(15).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12], + elements[13], + elements[14] + ); + } + + /// + /// Returns the result of applying a function to a sequence of 16 elements. + /// + /// + /// This operator uses immediate execution and buffers as many items of the source sequence as necessary. + /// + /// + /// Type of element in the source sequence + /// + /// + /// Type of the result + /// + /// + /// The sequence of items to fold. + /// + /// + /// Function to apply to the elements in the sequence. + /// + /// + /// The folded value returned by . + /// + /// + /// or is . + /// + /// + /// does not contain exactly 16 elements. + /// + public static TResult Fold( + this global::System.Collections.Generic.IEnumerable source, + global::System.Func folder + ) + { + ArgumentNullException.ThrowIfNull(source); + ArgumentNullException.ThrowIfNull(folder); + + var elements = source.AssertCount(16).ToList(); + + return folder( + elements[0], + elements[1], + elements[2], + elements[3], + elements[4], + elements[5], + elements[6], + elements[7], + elements[8], + elements[9], + elements[10], + elements[11], + elements[12], + elements[13], + elements[14], + elements[15] + ); + } + +} diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipLongest.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipLongest.g.cs index 992e7c8e..e8c36830 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipLongest.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipLongest.g.cs @@ -1,412 +1,583 @@ namespace SuperLinq; + #nullable enable + public static partial class SuperEnumerable { - private static bool DoRead(bool flag, IEnumerator iter, out T? value) - { - if (!flag || !iter.MoveNext()) - { - value = default; - return false; - } - - value = iter.Current; - return true; - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable ZipLongest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2) - { - return new ZipLongestIterator(list1, list2, resultSelector); - } - - return Core(first, second, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - var f1 = true; - using var e2 = second.GetEnumerator(); - var f2 = true; - while ((f1 = DoRead(f1, e1, out var v1)) | (f2 = DoRead(f2, e2, out var v2))) - { - yield return resultSelector(v1, v2); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// A sequence of containing corresponding elements from each - /// of the sequences. - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1? , T2? )> ZipLongest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second) => ZipLongest(first, second, global::System.ValueTuple.Create); - private sealed class ZipLongestIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Func _resultSelector; - public ZipLongestIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _resultSelector = resultSelector; - } - - public override int Count => Max(_list1.Count, _list2.Count); - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(i < _list1.Count ? _list1[i] : default, i < _list2.Count ? _list2[i] : default); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(index < _list1.Count ? _list1[index] : default, index < _list2.Count ? _list2[index] : default); - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable ZipLongest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2 && third is global::System.Collections.Generic.IList list3) - { - return new ZipLongestIterator(list1, list2, list3, resultSelector); - } - - return Core(first, second, third, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - var f1 = true; - using var e2 = second.GetEnumerator(); - var f2 = true; - using var e3 = third.GetEnumerator(); - var f3 = true; - while ((f1 = DoRead(f1, e1, out var v1)) | (f2 = DoRead(f2, e2, out var v2)) | (f3 = DoRead(f3, e3, out var v3))) - { - yield return resultSelector(v1, v2, v3); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// A sequence of containing corresponding elements from each - /// of the sequences. - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1? , T2? , T3? )> ZipLongest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third) => ZipLongest(first, second, third, global::System.ValueTuple.Create); - private sealed class ZipLongestIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Collections.Generic.IList _list3; - private readonly global::System.Func _resultSelector; - public ZipLongestIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Collections.Generic.IList third, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _list3 = third; - _resultSelector = resultSelector; - } - - public override int Count => Max(_list1.Count, _list2.Count, _list3.Count); - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(i < _list1.Count ? _list1[i] : default, i < _list2.Count ? _list2[i] : default, i < _list3.Count ? _list3[i] : default); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(index < _list1.Count ? _list1[index] : default, index < _list2.Count ? _list2[index] : default, index < _list3.Count ? _list3[index] : default); - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable ZipLongest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2 && third is global::System.Collections.Generic.IList list3 && fourth is global::System.Collections.Generic.IList list4) - { - return new ZipLongestIterator(list1, list2, list3, list4, resultSelector); - } - - return Core(first, second, third, fourth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - var f1 = true; - using var e2 = second.GetEnumerator(); - var f2 = true; - using var e3 = third.GetEnumerator(); - var f3 = true; - using var e4 = fourth.GetEnumerator(); - var f4 = true; - while ((f1 = DoRead(f1, e1, out var v1)) | (f2 = DoRead(f2, e2, out var v2)) | (f3 = DoRead(f3, e3, out var v3)) | (f4 = DoRead(f4, e4, out var v4))) - { - yield return resultSelector(v1, v2, v3, v4); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// A sequence of containing corresponding elements from each - /// of the sequences. - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(T1? , T2? , T3? , T4? )> ZipLongest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth) => ZipLongest(first, second, third, fourth, global::System.ValueTuple.Create); - private sealed class ZipLongestIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Collections.Generic.IList _list3; - private readonly global::System.Collections.Generic.IList _list4; - private readonly global::System.Func _resultSelector; - public ZipLongestIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Collections.Generic.IList third, global::System.Collections.Generic.IList fourth, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _list3 = third; - _list4 = fourth; - _resultSelector = resultSelector; - } - - public override int Count => Max(_list1.Count, _list2.Count, _list3.Count, _list4.Count); - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(i < _list1.Count ? _list1[i] : default, i < _list2.Count ? _list2[i] : default, i < _list3.Count ? _list3[i] : default, i < _list4.Count ? _list4[i] : default); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(index < _list1.Count ? _list1[index] : default, index < _list2.Count ? _list2[index] : default, index < _list3.Count ? _list3[index] : default, index < _list4.Count ? _list4[index] : default); - } - } -} \ No newline at end of file + private static bool DoRead(bool flag, IEnumerator iter, out T? value) + { + if (!flag || !iter.MoveNext()) + { + value = default; + return false; + } + + value = iter.Current; + return true; + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable ZipLongest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2) + { + return new ZipLongestIterator( + list1, + list2, + resultSelector + ); + } + + return Core( + first, + second, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + var f1 = true; + using var e2 = second.GetEnumerator(); + var f2 = true; + + while ( + (f1 = DoRead(f1, e1, out var v1)) + | (f2 = DoRead(f2, e2, out var v2)) + ) + { + yield return resultSelector( + v1, + v2 + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// A sequence of containing corresponding elements from each + /// of the sequences. + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1?,T2?)> + ZipLongest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second + ) => ZipLongest(first, second, global::System.ValueTuple.Create); + + private sealed class ZipLongestIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Func _resultSelector; + + public ZipLongestIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _resultSelector = resultSelector; + } + + public override int Count => Max(_list1.Count, _list2.Count); + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + i < _list1.Count ? _list1[i] : default, + i < _list2.Count ? _list2[i] : default + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + index < _list1.Count ? _list1[index] : default, + index < _list2.Count ? _list2[index] : default + ); + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable ZipLongest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2&& + third is global::System.Collections.Generic.IList list3) + { + return new ZipLongestIterator( + list1, + list2, + list3, + resultSelector + ); + } + + return Core( + first, + second, + third, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + var f1 = true; + using var e2 = second.GetEnumerator(); + var f2 = true; + using var e3 = third.GetEnumerator(); + var f3 = true; + + while ( + (f1 = DoRead(f1, e1, out var v1)) + | (f2 = DoRead(f2, e2, out var v2)) + | (f3 = DoRead(f3, e3, out var v3)) + ) + { + yield return resultSelector( + v1, + v2, + v3 + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// A sequence of containing corresponding elements from each + /// of the sequences. + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1?,T2?,T3?)> + ZipLongest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third + ) => ZipLongest(first, second, third, global::System.ValueTuple.Create); + + private sealed class ZipLongestIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Collections.Generic.IList _list3; + private readonly global::System.Func _resultSelector; + + public ZipLongestIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Collections.Generic.IList third, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _list3 = third; + _resultSelector = resultSelector; + } + + public override int Count => Max(_list1.Count, _list2.Count, _list3.Count); + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + i < _list1.Count ? _list1[i] : default, + i < _list2.Count ? _list2[i] : default, + i < _list3.Count ? _list3[i] : default + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + index < _list1.Count ? _list1[index] : default, + index < _list2.Count ? _list2[index] : default, + index < _list3.Count ? _list3[index] : default + ); + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable ZipLongest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2&& + third is global::System.Collections.Generic.IList list3&& + fourth is global::System.Collections.Generic.IList list4) + { + return new ZipLongestIterator( + list1, + list2, + list3, + list4, + resultSelector + ); + } + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + var f1 = true; + using var e2 = second.GetEnumerator(); + var f2 = true; + using var e3 = third.GetEnumerator(); + var f3 = true; + using var e4 = fourth.GetEnumerator(); + var f4 = true; + + while ( + (f1 = DoRead(f1, e1, out var v1)) + | (f2 = DoRead(f2, e2, out var v2)) + | (f3 = DoRead(f3, e3, out var v3)) + | (f4 = DoRead(f4, e4, out var v4)) + ) + { + yield return resultSelector( + v1, + v2, + v3, + v4 + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// A sequence of containing corresponding elements from each + /// of the sequences. + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(T1?,T2?,T3?,T4?)> + ZipLongest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth + ) => ZipLongest(first, second, third, fourth, global::System.ValueTuple.Create); + + private sealed class ZipLongestIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Collections.Generic.IList _list3; + private readonly global::System.Collections.Generic.IList _list4; + private readonly global::System.Func _resultSelector; + + public ZipLongestIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Collections.Generic.IList third, + global::System.Collections.Generic.IList fourth, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _list3 = third; + _list4 = fourth; + _resultSelector = resultSelector; + } + + public override int Count => Max(_list1.Count, _list2.Count, _list3.Count, _list4.Count); + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + i < _list1.Count ? _list1[i] : default, + i < _list2.Count ? _list2[i] : default, + i < _list3.Count ? _list3[i] : default, + i < _list4.Count ? _list4[i] : default + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + index < _list1.Count ? _list1[index] : default, + index < _list2.Count ? _list2[index] : default, + index < _list3.Count ? _list3[index] : default, + index < _list4.Count ? _list4[index] : default + ); + } + } + +} diff --git a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipShortest.g.cs b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipShortest.g.cs index acbfc758..5f2f7ed8 100644 --- a/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipShortest.g.cs +++ b/Source/SuperLinq/Generated/SuperLinq.Generator/SuperLinq.Generator.Generator/ZipShortest.g.cs @@ -1,388 +1,559 @@ namespace SuperLinq; + #nullable enable + public static partial class SuperEnumerable { - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable ZipShortest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2) - { - return new ZipShortestIterator(list1, list2, resultSelector); - } - - return Core(first, second, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - using var e2 = second.GetEnumerator(); - while (e1.MoveNext() && e2.MoveNext()) - { - yield return resultSelector(e1.Current, e2.Current); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// A sequence of containing corresponding elements from each - /// of the sequences. - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(TFirst, TSecond)> ZipShortest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second) => ZipShortest(first, second, global::System.ValueTuple.Create); - private sealed class ZipShortestIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Func _resultSelector; - public ZipShortestIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _resultSelector = resultSelector; - } - - public override int Count => Min(_list1.Count, _list2.Count); - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(_list1[i], _list2[i]); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(_list1[index], _list2[index]); - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable ZipShortest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2 && third is global::System.Collections.Generic.IList list3) - { - return new ZipShortestIterator(list1, list2, list3, resultSelector); - } - - return Core(first, second, third, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - using var e2 = second.GetEnumerator(); - using var e3 = third.GetEnumerator(); - while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext()) - { - yield return resultSelector(e1.Current, e2.Current, e3.Current); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// A sequence of containing corresponding elements from each - /// of the sequences. - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(TFirst, TSecond, TThird)> ZipShortest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third) => ZipShortest(first, second, third, global::System.ValueTuple.Create); - private sealed class ZipShortestIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Collections.Generic.IList _list3; - private readonly global::System.Func _resultSelector; - public ZipShortestIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Collections.Generic.IList third, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _list3 = third; - _resultSelector = resultSelector; - } - - public override int Count => Min(_list1.Count, _list2.Count, _list3.Count); - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(_list1[i], _list2[i], _list3[i]); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(_list1[index], _list2[index], _list3[index]); - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence is as short as the shortest input sequence. - /// - /// - /// The type of the elements of the result sequence. - /// - /// - /// A projection function that combines elements from all of the sequences. - /// - /// - /// A sequence of elements returned by . - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// or any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable ZipShortest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - ArgumentNullException.ThrowIfNull(first); - ArgumentNullException.ThrowIfNull(second); - ArgumentNullException.ThrowIfNull(third); - ArgumentNullException.ThrowIfNull(fourth); - ArgumentNullException.ThrowIfNull(resultSelector); - if (first is global::System.Collections.Generic.IList list1 && second is global::System.Collections.Generic.IList list2 && third is global::System.Collections.Generic.IList list3 && fourth is global::System.Collections.Generic.IList list4) - { - return new ZipShortestIterator(list1, list2, list3, list4, resultSelector); - } - - return Core(first, second, third, fourth, resultSelector); - static global::System.Collections.Generic.IEnumerable Core(global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth, global::System.Func resultSelector) - { - using var e1 = first.GetEnumerator(); - using var e2 = second.GetEnumerator(); - using var e3 = third.GetEnumerator(); - using var e4 = fourth.GetEnumerator(); - while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext() && e4.MoveNext()) - { - yield return resultSelector(e1.Current, e2.Current, e3.Current, e4.Current); - } - } - } - - /// - /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument - /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default - /// value of each of the shorter sequence element types is used for padding. - /// - /// - /// A sequence of containing corresponding elements from each - /// of the sequences. - /// - /// - /// This method uses deferred execution and streams its results. - /// - /// - /// Any of the input sequences is . - /// - /// - /// The type of the elements of . - /// - /// - /// The first sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The second sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The third sequence of elements. - /// - /// - /// The type of the elements of . - /// - /// - /// The fourth sequence of elements. - /// - public static global::System.Collections.Generic.IEnumerable<(TFirst, TSecond, TThird, TFourth)> ZipShortest(this global::System.Collections.Generic.IEnumerable first, global::System.Collections.Generic.IEnumerable second, global::System.Collections.Generic.IEnumerable third, global::System.Collections.Generic.IEnumerable fourth) => ZipShortest(first, second, third, fourth, global::System.ValueTuple.Create); - private sealed class ZipShortestIterator : ListIterator - { - private readonly global::System.Collections.Generic.IList _list1; - private readonly global::System.Collections.Generic.IList _list2; - private readonly global::System.Collections.Generic.IList _list3; - private readonly global::System.Collections.Generic.IList _list4; - private readonly global::System.Func _resultSelector; - public ZipShortestIterator(global::System.Collections.Generic.IList first, global::System.Collections.Generic.IList second, global::System.Collections.Generic.IList third, global::System.Collections.Generic.IList fourth, global::System.Func resultSelector) - { - _list1 = first; - _list2 = second; - _list3 = third; - _list4 = fourth; - _resultSelector = resultSelector; - } - - public override int Count => Min(_list1.Count, _list2.Count, _list3.Count, _list4.Count); - - protected override IEnumerable GetEnumerable() - { - var cnt = (uint)Count; - for (var i = 0; i < cnt; i++) - { - yield return _resultSelector(_list1[i], _list2[i], _list3[i], _list4[i]); - } - } - - protected override TResult ElementAt(int index) - { - ArgumentOutOfRangeException.ThrowIfNegative(index); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); - return _resultSelector(_list1[index], _list2[index], _list3[index], _list4[index]); - } - } -} \ No newline at end of file + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable ZipShortest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2) + { + return new ZipShortestIterator( + list1, + list2, + resultSelector + ); + } + + return Core( + first, + second, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + using var e2 = second.GetEnumerator(); + + while ( + e1.MoveNext() + && e2.MoveNext() + ) + { + yield return resultSelector( + e1.Current, + e2.Current + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// A sequence of containing corresponding elements from each + /// of the sequences. + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(TFirst,TSecond)> + ZipShortest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second + ) => ZipShortest(first, second, global::System.ValueTuple.Create); + + private sealed class ZipShortestIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Func _resultSelector; + + public ZipShortestIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _resultSelector = resultSelector; + } + + public override int Count => Min(_list1.Count, _list2.Count); + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + _list1[i], + _list2[i] + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + _list1[index], + _list2[index] + ); + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable ZipShortest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2&& + third is global::System.Collections.Generic.IList list3) + { + return new ZipShortestIterator( + list1, + list2, + list3, + resultSelector + ); + } + + return Core( + first, + second, + third, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + using var e2 = second.GetEnumerator(); + using var e3 = third.GetEnumerator(); + + while ( + e1.MoveNext() + && e2.MoveNext() + && e3.MoveNext() + ) + { + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// A sequence of containing corresponding elements from each + /// of the sequences. + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(TFirst,TSecond,TThird)> + ZipShortest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third + ) => ZipShortest(first, second, third, global::System.ValueTuple.Create); + + private sealed class ZipShortestIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Collections.Generic.IList _list3; + private readonly global::System.Func _resultSelector; + + public ZipShortestIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Collections.Generic.IList third, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _list3 = third; + _resultSelector = resultSelector; + } + + public override int Count => Min(_list1.Count, _list2.Count, _list3.Count); + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + _list1[i], + _list2[i], + _list3[i] + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + _list1[index], + _list2[index], + _list3[index] + ); + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence is as short as the shortest input sequence. + /// + /// + /// The type of the elements of the result sequence. + /// + /// + /// A projection function that combines elements from all of the sequences. + /// + /// + /// A sequence of elements returned by . + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// or any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable ZipShortest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + ArgumentNullException.ThrowIfNull(first); + ArgumentNullException.ThrowIfNull(second); + ArgumentNullException.ThrowIfNull(third); + ArgumentNullException.ThrowIfNull(fourth); + + ArgumentNullException.ThrowIfNull(resultSelector); + + if ( + first is global::System.Collections.Generic.IList list1&& + second is global::System.Collections.Generic.IList list2&& + third is global::System.Collections.Generic.IList list3&& + fourth is global::System.Collections.Generic.IList list4) + { + return new ZipShortestIterator( + list1, + list2, + list3, + list4, + resultSelector + ); + } + + return Core( + first, + second, + third, + fourth, + resultSelector + ); + + static global::System.Collections.Generic.IEnumerable Core( + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth, + global::System.Func resultSelector + ) + { + using var e1 = first.GetEnumerator(); + using var e2 = second.GetEnumerator(); + using var e3 = third.GetEnumerator(); + using var e4 = fourth.GetEnumerator(); + + while ( + e1.MoveNext() + && e2.MoveNext() + && e3.MoveNext() + && e4.MoveNext() + ) + { + yield return resultSelector( + e1.Current, + e2.Current, + e3.Current, + e4.Current + ); + } + } + } + + /// + /// Returns a projection of tuples, where each tuple contains the N-th element from each of the argument + /// sequences. The resulting sequence will always be as long as the longest of input sequences where the default + /// value of each of the shorter sequence element types is used for padding. + /// + /// + /// A sequence of containing corresponding elements from each + /// of the sequences. + /// + /// + /// This method uses deferred execution and streams its results. + /// + /// + /// Any of the input sequences is . + /// + /// + /// The type of the elements of . + /// + /// + /// The first sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The second sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The third sequence of elements. + /// + /// + /// The type of the elements of . + /// + /// + /// The fourth sequence of elements. + /// + public static global::System.Collections.Generic.IEnumerable<(TFirst,TSecond,TThird,TFourth)> + ZipShortest(this + global::System.Collections.Generic.IEnumerable first, + global::System.Collections.Generic.IEnumerable second, + global::System.Collections.Generic.IEnumerable third, + global::System.Collections.Generic.IEnumerable fourth + ) => ZipShortest(first, second, third, fourth, global::System.ValueTuple.Create); + + private sealed class ZipShortestIterator : ListIterator + { + private readonly global::System.Collections.Generic.IList _list1; + private readonly global::System.Collections.Generic.IList _list2; + private readonly global::System.Collections.Generic.IList _list3; + private readonly global::System.Collections.Generic.IList _list4; + private readonly global::System.Func _resultSelector; + + public ZipShortestIterator( + global::System.Collections.Generic.IList first, + global::System.Collections.Generic.IList second, + global::System.Collections.Generic.IList third, + global::System.Collections.Generic.IList fourth, + global::System.Func resultSelector + ) + { + _list1 = first; + _list2 = second; + _list3 = third; + _list4 = fourth; + _resultSelector = resultSelector; + } + + public override int Count => Min(_list1.Count, _list2.Count, _list3.Count, _list4.Count); + + protected override IEnumerable GetEnumerable() + { + var cnt = (uint)Count; + for (var i = 0; i < cnt; i++) + { + yield return _resultSelector( + _list1[i], + _list2[i], + _list3[i], + _list4[i] + ); + } + } + + protected override TResult ElementAt(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Count); + + return _resultSelector( + _list1[index], + _list2[index], + _list3[index], + _list4[index] + ); + } + } + +} diff --git a/Tests/SuperLinq.Test/CartesianTest.cs b/Tests/SuperLinq.Test/CartesianTest.cs index 73834cd9..7adb6ff2 100644 --- a/Tests/SuperLinq.Test/CartesianTest.cs +++ b/Tests/SuperLinq.Test/CartesianTest.cs @@ -1,4 +1,4 @@ -namespace Test; +namespace Test; /// /// Verify the behavior of the Cartesian operator @@ -12,8 +12,10 @@ public class CartesianTests public void TestCartesianIsLazy() { _ = new BreakingSequence() - .Cartesian(new BreakingSequence(), - BreakingFunc.Of()); + .Cartesian( + new BreakingSequence(), + BreakingFunc.Of() + ); } /// @@ -43,14 +45,14 @@ public void TestCartesianOfEmptyAndNonEmpty() using (var tsB = sequenceB.AsTestingSequence()) { var result = tsA.Cartesian(tsB, (a, b) => a + b); - Assert.Equal(sequenceA, result); + result.AssertSequenceEqual(sequenceA); } - using (var tsA = sequenceA.AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts)) - using (var tsB = sequenceB.AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts)) + using (var tsA = sequenceA.AsTestingSequence()) + using (var tsB = sequenceB.AsTestingSequence()) { var result = tsB.Cartesian(tsA, (a, b) => a + b); - Assert.Equal(sequenceA, result); + result.AssertSequenceEqual(sequenceA); } } @@ -60,8 +62,8 @@ public void TestCartesianOfEmptyAndNonEmpty() [Fact] public void TestCartesianProductCount() { - using var sequenceA = Enumerable.Range(1, 100).AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); - using var sequenceB = Enumerable.Range(1, 75).AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); + using var sequenceA = Enumerable.Range(1, 100).AsTestingSequence(); + using var sequenceB = Enumerable.Range(1, 75).AsTestingSequence(); var result = sequenceA.Cartesian(sequenceB, (a, b) => a + b); @@ -80,10 +82,10 @@ public void TestCartesianProductCountMultidimensional() const int CountC = 8; const int CountD = 7; - using var sequenceA = Enumerable.Range(1, CountA).AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); - using var sequenceB = Enumerable.Range(1, CountB).AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); - using var sequenceC = Enumerable.Range(1, CountC).AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); - using var sequenceD = Enumerable.Range(1, CountD).AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); + using var sequenceA = Enumerable.Range(1, CountA).AsTestingSequence(); + using var sequenceB = Enumerable.Range(1, CountB).AsTestingSequence(); + using var sequenceC = Enumerable.Range(1, CountC).AsTestingSequence(); + using var sequenceD = Enumerable.Range(1, CountD).AsTestingSequence(); var result = sequenceA.Cartesian(sequenceB, sequenceC, sequenceD, (a, b, c, d) => a + b + c + d); @@ -109,11 +111,12 @@ public void TestCartesianProductCombinations() Enumerable.Repeat(element: false, 5).ToArray(), }; - using var tsA = sequenceA.AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); - using var tsB = sequenceB.AsTestingSequence(TestingSequence.Options.AllowRepeatedMoveNexts); + using var tsA = sequenceA.AsTestingSequence(); + using var tsB = sequenceB.AsTestingSequence(); - var result = tsA.Cartesian(tsB, (a, b) => new { A = a, B = b }) - .ToArray(); + var result = tsA + .Cartesian(tsB, (a, b) => new { A = a, B = b }) + .ToArray(); // verify that the expected number of results is correct Assert.Equal(sequenceA.Count() * sequenceB.Count(), result.Length); @@ -124,21 +127,24 @@ public void TestCartesianProductCombinations() Assert.True(expectedSet.SelectMany(SuperEnumerable.Identity).All(SuperEnumerable.Identity)); } - /// - /// Verify that if either sequence passed to Cartesian is empty, the result - /// is an empty sequence. - /// [Fact] - public void TestEmptyCartesianEvaluation() + public void TestAllCartesianMethods() { - var sequence = Enumerable.Range(0, 5); - - var resultA = sequence.Cartesian(Enumerable.Empty(), (a, b) => new { A = a, B = b }); - var resultB = Enumerable.Empty().Cartesian(sequence, (a, b) => new { A = a, B = b }); - var resultC = Enumerable.Empty().Cartesian(Enumerable.Empty(), (a, b) => new { A = a, B = b }); - - Assert.Empty(resultA); - Assert.Empty(resultB); - Assert.Empty(resultC); + using var ts1 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 7); + using var ts2 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 7); + using var ts3 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 6); + using var ts4 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 5); + using var ts5 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 4); + using var ts6 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 3); + using var ts7 = Enumerable.Range(0, 1).AsTestingSequence(maxEnumerations: 2); + using var ts8 = Enumerable.Range(0, 1).AsTestingSequence(); + + ts1.Cartesian(ts2).AssertSequenceEqual((0, 0)); + ts1.Cartesian(ts2, ts3).AssertSequenceEqual((0, 0, 0)); + ts1.Cartesian(ts2, ts3, ts4).AssertSequenceEqual((0, 0, 0, 0)); + ts1.Cartesian(ts2, ts3, ts4, ts5).AssertSequenceEqual((0, 0, 0, 0, 0)); + ts1.Cartesian(ts2, ts3, ts4, ts5, ts6).AssertSequenceEqual((0, 0, 0, 0, 0, 0)); + ts1.Cartesian(ts2, ts3, ts4, ts5, ts6, ts7).AssertSequenceEqual((0, 0, 0, 0, 0, 0, 0)); + ts1.Cartesian(ts2, ts3, ts4, ts5, ts6, ts7, ts8).AssertSequenceEqual((0, 0, 0, 0, 0, 0, 0, 0)); } }