From 7a084f4cdf86447b83cc3a30c4c0afbb75169011 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 15 Jun 2019 20:38:01 +0200 Subject: [PATCH 01/40] Tuple-returning overload for Pairwise --- MoreLinq.Test/PairwiseTest.cs | 59 ++++++++++++++++++++++++++--------- MoreLinq/Pairwise.cs | 20 ++++++++++++ 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/MoreLinq.Test/PairwiseTest.cs b/MoreLinq.Test/PairwiseTest.cs index 7d84355f4..2befcc8a4 100644 --- a/MoreLinq.Test/PairwiseTest.cs +++ b/MoreLinq.Test/PairwiseTest.cs @@ -22,27 +22,56 @@ namespace MoreLinq.Test [TestFixture] public class PairwiseTest { - [Test] - public void PairwiseIsLazy() + public class ReturningTuples { - new BreakingSequence().Pairwise(BreakingFunc.Of()); - } + [Test] + public void PairwiseIsLazy() + { + new BreakingSequence().Pairwise(); + } - [TestCase(0)] - [TestCase(1)] - public void PairwiseWithSequenceShorterThanTwo(int count) - { - var source = Enumerable.Range(0, count); - var result = source.Pairwise(BreakingFunc.Of()); + [TestCase(0)] + [TestCase(1)] + public void PairwiseWithSequenceShorterThanTwo(int count) + { + var source = Enumerable.Range(0, count); + var result = source.Pairwise(); + + Assert.That(result, Is.Empty); + } - Assert.That(result, Is.Empty); + [Test] + public void PairwiseWideSourceSequence() + { + var result = new[] { "a", "b", "c", "d" }.Pairwise(); + result.AssertSequenceEqual(("a", "b"), ("b", "c"), ("c", "d")); + } } - [Test] - public void PairwiseWideSourceSequence() + public class ReturningSomeResults { - var result = new[] { "a", "b", "c", "d" }.Pairwise((x, y) => x + y); - result.AssertSequenceEqual("ab", "bc", "cd"); + [Test] + public void PairwiseIsLazy() + { + new BreakingSequence().Pairwise(BreakingFunc.Of()); + } + + [TestCase(0)] + [TestCase(1)] + public void PairwiseWithSequenceShorterThanTwo(int count) + { + var source = Enumerable.Range(0, count); + var result = source.Pairwise(BreakingFunc.Of()); + + Assert.That(result, Is.Empty); + } + + [Test] + public void PairwiseWideSourceSequence() + { + var result = new[] { "a", "b", "c", "d" }.Pairwise((x, y) => x + y); + result.AssertSequenceEqual("ab", "bc", "cd"); + } } } } diff --git a/MoreLinq/Pairwise.cs b/MoreLinq/Pairwise.cs index 64b42df0d..27fca9277 100644 --- a/MoreLinq/Pairwise.cs +++ b/MoreLinq/Pairwise.cs @@ -22,6 +22,26 @@ namespace MoreLinq static partial class MoreEnumerable { + /// + /// Returns a sequence where each element in the source sequence is + /// paired with its predecessor, with the exception of the first + /// element which is only returned as the predecessor of the second + /// element. + /// + /// + /// The type of the elements of . + /// The source sequence. + /// + /// Returns the resulting sequence. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(TSource, TSource)> + Pairwise(this IEnumerable source) => + Pairwise(source, ValueTuple.Create); + /// /// Returns a sequence resulting from applying a function to each /// element in the source sequence and its From 9d158e33249332d8abd317c0d1215cd686463a08 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 15 Jun 2019 20:51:33 +0200 Subject: [PATCH 02/40] Generate Pairwise overload wrapper --- MoreLinq/Extensions.g.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index bacd98196..b05a29cb7 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -3524,6 +3524,25 @@ public static IEnumerable PadStart(this IEnumerable s [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class PairwiseExtension { + /// + /// Returns a sequence where each element in the source sequence is + /// paired with its predecessor, with the exception of the first + /// element which is only returned as the predecessor of the second + /// element. + /// + /// + /// The type of the elements of . + /// The source sequence. + /// + /// Returns the resulting sequence. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(TSource, TSource)> + Pairwise(this IEnumerable source) => MoreEnumerable. Pairwise(source); + /// /// Returns a sequence resulting from applying a function to each /// element in the source sequence and its From 1b33fb1932a68dd4d057bd01e517bd4a145b0693 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 30 Oct 2019 17:04:50 +0100 Subject: [PATCH 03/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index d9778b56f..06ce18380 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -650,7 +650,21 @@ public static partial class BatchExtension /// Size of buckets. /// A sequence of equally sized buckets containing elements of the source collection. /// - /// This operator uses deferred execution and streams its results (buckets and bucket content). + /// + /// This operator uses deferred execution and streams its results + /// (buckets are streamed but their content buffered). + /// + /// When more than one bucket is streamed, all buckets except the last + /// is guaranteed to have elements. The last + /// bucket may be smaller depending on the remaining elements in the + /// sequence. + /// + /// Each bucket is pre-allocated to elements. + /// If is set to a very large value, e.g. + /// to effectively disable batching by just + /// hoping for a single bucket, then it can lead to memory exhaustion + /// (). + /// /// public static IEnumerable> Batch(this IEnumerable source, int size) @@ -665,9 +679,21 @@ public static IEnumerable> Batch(this IEnumerable< /// Size of buckets. /// The projection to apply to each bucket. /// A sequence of projections on equally sized buckets containing elements of the source collection. - /// - /// This operator uses deferred execution and streams its results (buckets and bucket content). - /// + /// + /// This operator uses deferred execution and streams its results + /// (buckets are streamed but their content buffered). + /// + /// + /// When more than one bucket is streamed, all buckets except the last + /// is guaranteed to have elements. The last + /// bucket may be smaller depending on the remaining elements in the + /// sequence. + /// Each bucket is pre-allocated to elements. + /// If is set to a very large value, e.g. + /// to effectively disable batching by just + /// hoping for a single bucket, then it can lead to memory exhaustion + /// (). + /// public static IEnumerable Batch(this IEnumerable source, int size, Func, TResult> resultSelector) From 16af855419bfb8746a7fc448ee5808ca8a60db98 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 30 Oct 2019 17:06:10 +0100 Subject: [PATCH 04/40] Update README with Pairwise overload count --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d6923b81d..0e89818a6 100644 --- a/README.md +++ b/README.md @@ -418,6 +418,8 @@ Returns a sequence resulting from applying a function to each element in the source sequence and its predecessor, with the exception of the first element which is only returned as the predecessor of the second element +This method has 2 overloads. + ### PartialSort Combines `OrderBy` (where element is key) and `Take` in a single operation. From 96506e7a6f34d14ade382d909949fd78257eef0e Mon Sep 17 00:00:00 2001 From: Orace Date: Wed, 30 Oct 2019 17:34:01 +0100 Subject: [PATCH 05/40] Tuple-returning overload for EquiZip --- MoreLinq.Test/EquiZipTest.cs | 204 +++++++++++++++++++++++++---------- MoreLinq/EquiZip.cs | 124 +++++++++++++++++++++ 2 files changed, 270 insertions(+), 58 deletions(-) diff --git a/MoreLinq.Test/EquiZipTest.cs b/MoreLinq.Test/EquiZipTest.cs index 8ca05f1d5..8918164db 100644 --- a/MoreLinq.Test/EquiZipTest.cs +++ b/MoreLinq.Test/EquiZipTest.cs @@ -24,85 +24,173 @@ namespace MoreLinq.Test [TestFixture] public class EquiZipTest { - [Test] - public void BothSequencesDisposedWithUnequalLengthsAndLongerFirst() + public class WithTuple { - using (var longer = TestingSequence.Of(1, 2, 3)) - using (var shorter = TestingSequence.Of(1, 2)) + [Test] + public void BothSequencesDisposedWithUnequalLengthsAndLongerFirst() { - // Yes, this will throw... but then we should still have disposed both sequences + using (var longer = TestingSequence.Of(1, 2, 3)) + using (var shorter = TestingSequence.Of(1, 2)) + { + // Yes, this will throw... but then we should still have disposed both sequences + Assert.Throws(() => + longer.EquiZip(shorter).Consume()); + } + } + + [Test] + public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst() + { + using (var longer = TestingSequence.Of(1, 2, 3)) + using (var shorter = TestingSequence.Of(1, 2)) + { + // Yes, this will throw... but then we should still have disposed both sequences + Assert.Throws(() => + shorter.EquiZip(longer).Consume()); + } + } + + [Test] + public void ZipWithEqualLengthSequencesFailStrategy() + { + var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5, 6 }); + Assert.That(zipped, Is.Not.Null); + zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6)); + } + + [Test] + public void ZipWithFirstSequenceShorterThanSecondFailStrategy() + { + var zipped = new[] { 1, 2 }.EquiZip(new[] { 4, 5, 6 }); + Assert.That(zipped, Is.Not.Null); Assert.Throws(() => - longer.EquiZip(shorter, (x, y) => x + y).Consume()); + zipped.Consume()); } - } - [Test] - public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst() - { - using (var longer = TestingSequence.Of(1, 2, 3)) - using (var shorter = TestingSequence.Of(1, 2)) + [Test] + public void ZipWithFirstSequnceLongerThanSecondFailStrategy() { - // Yes, this will throw... but then we should still have disposed both sequences + var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5 }); + Assert.That(zipped, Is.Not.Null); Assert.Throws(() => - shorter.EquiZip(longer, (x, y) => x + y).Consume()); + zipped.Consume()); } - } - [Test] - public void ZipWithEqualLengthSequencesFailStrategy() - { - var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5, 6 }, Tuple.Create); - Assert.That(zipped, Is.Not.Null); - zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6)); - } + [Test] + public void ZipIsLazy() + { + var bs = new BreakingSequence(); + bs.EquiZip(bs); + } - [Test] - public void ZipWithFirstSequenceShorterThanSecondFailStrategy() - { - var zipped = new[] { 1, 2 }.EquiZip(new[] { 4, 5, 6 }, Tuple.Create); - Assert.That(zipped, Is.Not.Null); - Assert.Throws(() => - zipped.Consume()); - } + [Test] + public void MoveNextIsNotCalledUnnecessarily() + { + using (var s1 = TestingSequence.Of(1, 2)) + using (var s2 = TestingSequence.Of(1, 2, 3)) + using (var s3 = MoreEnumerable.From(() => 1, + () => 2, + () => throw new TestException()) + .AsTestingSequence()) + { + Assert.Throws(() => + s1.EquiZip(s2, s3).Consume()); + } + } - [Test] - public void ZipWithFirstSequnceLongerThanSecondFailStrategy() - { - var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5 }, Tuple.Create); - Assert.That(zipped, Is.Not.Null); - Assert.Throws(() => - zipped.Consume()); + [Test] + public void ZipDisposesInnerSequencesCaseGetEnumeratorThrows() + { + using (var s1 = TestingSequence.Of(1, 2)) + { + Assert.Throws(() => + s1.EquiZip(new BreakingSequence()).Consume()); + } + } } - [Test] - public void ZipIsLazy() + public class WithResultSelector { - var bs = new BreakingSequence(); - bs.EquiZip(bs, BreakingFunc.Of()); - } + [Test] + public void BothSequencesDisposedWithUnequalLengthsAndLongerFirst() + { + using (var longer = TestingSequence.Of(1, 2, 3)) + using (var shorter = TestingSequence.Of(1, 2)) + { + // Yes, this will throw... but then we should still have disposed both sequences + Assert.Throws(() => + longer.EquiZip(shorter, (x, y) => x + y).Consume()); + } + } - [Test] - public void MoveNextIsNotCalledUnnecessarily() - { - using (var s1 = TestingSequence.Of(1, 2)) - using (var s2 = TestingSequence.Of(1, 2, 3)) - using (var s3 = MoreEnumerable.From(() => 1, - () => 2, - () => throw new TestException()) - .AsTestingSequence()) + [Test] + public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst() + { + using (var longer = TestingSequence.Of(1, 2, 3)) + using (var shorter = TestingSequence.Of(1, 2)) + { + // Yes, this will throw... but then we should still have disposed both sequences + Assert.Throws(() => + shorter.EquiZip(longer, (x, y) => x + y).Consume()); + } + } + + [Test] + public void ZipWithEqualLengthSequencesFailStrategy() + { + var zipped = new[] {1, 2, 3}.EquiZip(new[] {4, 5, 6}, Tuple.Create); + Assert.That(zipped, Is.Not.Null); + zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6)); + } + + [Test] + public void ZipWithFirstSequenceShorterThanSecondFailStrategy() { + var zipped = new[] {1, 2}.EquiZip(new[] {4, 5, 6}, Tuple.Create); + Assert.That(zipped, Is.Not.Null); Assert.Throws(() => - s1.EquiZip(s2, s3, (x, y, z) => x + y + z).Consume()); + zipped.Consume()); } - } - [Test] - public void ZipDisposesInnerSequencesCaseGetEnumeratorThrows() - { - using (var s1 = TestingSequence.Of(1, 2)) + [Test] + public void ZipWithFirstSequnceLongerThanSecondFailStrategy() { + var zipped = new[] {1, 2, 3}.EquiZip(new[] {4, 5}, Tuple.Create); + Assert.That(zipped, Is.Not.Null); Assert.Throws(() => - s1.EquiZip(new BreakingSequence(), Tuple.Create).Consume()); + zipped.Consume()); + } + + [Test] + public void ZipIsLazy() + { + var bs = new BreakingSequence(); + bs.EquiZip(bs, BreakingFunc.Of()); + } + + [Test] + public void MoveNextIsNotCalledUnnecessarily() + { + using (var s1 = TestingSequence.Of(1, 2)) + using (var s2 = TestingSequence.Of(1, 2, 3)) + using (var s3 = MoreEnumerable.From(() => 1, + () => 2, + () => throw new TestException()) + .AsTestingSequence()) + { + Assert.Throws(() => + s1.EquiZip(s2, s3, (x, y, z) => x + y + z).Consume()); + } + } + + [Test] + public void ZipDisposesInnerSequencesCaseGetEnumeratorThrows() + { + using (var s1 = TestingSequence.Of(1, 2)) + { + Assert.Throws(() => + s1.EquiZip(new BreakingSequence(), Tuple.Create).Consume()); + } } } } diff --git a/MoreLinq/EquiZip.cs b/MoreLinq/EquiZip.cs index edede6ef1..195eba49c 100644 --- a/MoreLinq/EquiZip.cs +++ b/MoreLinq/EquiZip.cs @@ -168,6 +168,130 @@ public static IEnumerable EquiZip( return EquiZipImpl(first, second, third, fourth, resultSelector); } + /// + /// Returns tuples, where each tuple contains the N-th + /// element from each of the argument sequences. An exception is thrown + /// if the input sequences are of different lengths. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// The first sequence. + /// The second sequence. + /// + /// A sequence of tuples that contains elements of the two input sequences. + /// + /// + /// The input sequences are of different lengths. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A), + /// (2, B), (3, C), (4, D) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2)> EquiZip(this IEnumerable first, IEnumerable second) + { + if (first == null) throw new ArgumentNullException(nameof(first)); + if (second == null) throw new ArgumentNullException(nameof(second)); + + return EquiZipImpl(first, second, null, null, (a, b, _, _) => ValueTuple.Create(a, b)); + } + + /// + /// Returns tuples, where each tuple contains the N-th + /// element from each of the argument sequences. An exception is thrown + /// if the input sequences are of different lengths. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// Type of elements in third sequence + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// + /// A sequence of tuples that contains elements of the three input sequences. + /// + /// + /// The input sequences are of different lengths. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A, a), + /// (2, B, b), (3, C, c), (4, D, d) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3)> EquiZip( + this IEnumerable first, + IEnumerable second, IEnumerable third) + { + if (first == null) throw new ArgumentNullException(nameof(first)); + if (second == null) throw new ArgumentNullException(nameof(second)); + if (third == null) throw new ArgumentNullException(nameof(third)); + + return EquiZipImpl(first, second, third, null, (a, b, c, _) => ValueTuple.Create(a, b, c)); + } + + /// + /// Returns tuples, where each tuple contains the N-th + /// element from each of the argument sequences. An exception is thrown + /// if the input sequences are of different lengths. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// Type of elements in third sequence + /// Type of elements in fourth sequence + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// The fourth sequence. + /// + /// A sequence of tuples that contains elements of the four input sequences. + /// + /// + /// The input sequences are of different lengths. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A, a, True), + /// (2, B, b, False), (3, C, c, True), (4, D, d, False) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> EquiZip( + this IEnumerable first, + IEnumerable second, IEnumerable third, IEnumerable fourth) + { + if (first == null) throw new ArgumentNullException(nameof(first)); + if (second == null) throw new ArgumentNullException(nameof(second)); + if (third == null) throw new ArgumentNullException(nameof(third)); + if (fourth == null) throw new ArgumentNullException(nameof(fourth)); + + return EquiZipImpl(first, second, third, fourth, ValueTuple.Create); + } + static IEnumerable EquiZipImpl( IEnumerable s1, IEnumerable s2, From 312865bcbcd8b2b4277b42d8dc98e8064d4b4dbf Mon Sep 17 00:00:00 2001 From: Orace Date: Wed, 30 Oct 2019 18:04:51 +0100 Subject: [PATCH 06/40] Fix build. --- MoreLinq/EquiZip.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/EquiZip.cs b/MoreLinq/EquiZip.cs index 195eba49c..21f418cc2 100644 --- a/MoreLinq/EquiZip.cs +++ b/MoreLinq/EquiZip.cs @@ -201,7 +201,7 @@ public static IEnumerable EquiZip( if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); - return EquiZipImpl(first, second, null, null, (a, b, _, _) => ValueTuple.Create(a, b)); + return EquiZipImpl(first, second, null, null, (a, b, c, d) => ValueTuple.Create(a, b)); } /// @@ -243,7 +243,7 @@ public static IEnumerable EquiZip( if (second == null) throw new ArgumentNullException(nameof(second)); if (third == null) throw new ArgumentNullException(nameof(third)); - return EquiZipImpl(first, second, third, null, (a, b, c, _) => ValueTuple.Create(a, b, c)); + return EquiZipImpl(first, second, third, null, (a, b, c, d) => ValueTuple.Create(a, b, c)); } /// From 0ba21fc5197c458c28772195c848ad444f1aa36c Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 09:32:16 +0100 Subject: [PATCH 07/40] Simplify implementation of EquiZip for tuple-returning --- MoreLinq.Test/EquiZipTest.cs | 204 ++++++++++------------------------- MoreLinq/EquiZip.cs | 18 +--- 2 files changed, 61 insertions(+), 161 deletions(-) diff --git a/MoreLinq.Test/EquiZipTest.cs b/MoreLinq.Test/EquiZipTest.cs index 8918164db..8ca05f1d5 100644 --- a/MoreLinq.Test/EquiZipTest.cs +++ b/MoreLinq.Test/EquiZipTest.cs @@ -24,173 +24,85 @@ namespace MoreLinq.Test [TestFixture] public class EquiZipTest { - public class WithTuple + [Test] + public void BothSequencesDisposedWithUnequalLengthsAndLongerFirst() { - [Test] - public void BothSequencesDisposedWithUnequalLengthsAndLongerFirst() + using (var longer = TestingSequence.Of(1, 2, 3)) + using (var shorter = TestingSequence.Of(1, 2)) { - using (var longer = TestingSequence.Of(1, 2, 3)) - using (var shorter = TestingSequence.Of(1, 2)) - { - // Yes, this will throw... but then we should still have disposed both sequences - Assert.Throws(() => - longer.EquiZip(shorter).Consume()); - } - } - - [Test] - public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst() - { - using (var longer = TestingSequence.Of(1, 2, 3)) - using (var shorter = TestingSequence.Of(1, 2)) - { - // Yes, this will throw... but then we should still have disposed both sequences - Assert.Throws(() => - shorter.EquiZip(longer).Consume()); - } - } - - [Test] - public void ZipWithEqualLengthSequencesFailStrategy() - { - var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5, 6 }); - Assert.That(zipped, Is.Not.Null); - zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6)); - } - - [Test] - public void ZipWithFirstSequenceShorterThanSecondFailStrategy() - { - var zipped = new[] { 1, 2 }.EquiZip(new[] { 4, 5, 6 }); - Assert.That(zipped, Is.Not.Null); + // Yes, this will throw... but then we should still have disposed both sequences Assert.Throws(() => - zipped.Consume()); + longer.EquiZip(shorter, (x, y) => x + y).Consume()); } + } - [Test] - public void ZipWithFirstSequnceLongerThanSecondFailStrategy() + [Test] + public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst() + { + using (var longer = TestingSequence.Of(1, 2, 3)) + using (var shorter = TestingSequence.Of(1, 2)) { - var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5 }); - Assert.That(zipped, Is.Not.Null); + // Yes, this will throw... but then we should still have disposed both sequences Assert.Throws(() => - zipped.Consume()); - } - - [Test] - public void ZipIsLazy() - { - var bs = new BreakingSequence(); - bs.EquiZip(bs); - } - - [Test] - public void MoveNextIsNotCalledUnnecessarily() - { - using (var s1 = TestingSequence.Of(1, 2)) - using (var s2 = TestingSequence.Of(1, 2, 3)) - using (var s3 = MoreEnumerable.From(() => 1, - () => 2, - () => throw new TestException()) - .AsTestingSequence()) - { - Assert.Throws(() => - s1.EquiZip(s2, s3).Consume()); - } + shorter.EquiZip(longer, (x, y) => x + y).Consume()); } + } - [Test] - public void ZipDisposesInnerSequencesCaseGetEnumeratorThrows() - { - using (var s1 = TestingSequence.Of(1, 2)) - { - Assert.Throws(() => - s1.EquiZip(new BreakingSequence()).Consume()); - } - } + [Test] + public void ZipWithEqualLengthSequencesFailStrategy() + { + var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5, 6 }, Tuple.Create); + Assert.That(zipped, Is.Not.Null); + zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6)); } - public class WithResultSelector + [Test] + public void ZipWithFirstSequenceShorterThanSecondFailStrategy() { - [Test] - public void BothSequencesDisposedWithUnequalLengthsAndLongerFirst() - { - using (var longer = TestingSequence.Of(1, 2, 3)) - using (var shorter = TestingSequence.Of(1, 2)) - { - // Yes, this will throw... but then we should still have disposed both sequences - Assert.Throws(() => - longer.EquiZip(shorter, (x, y) => x + y).Consume()); - } - } + var zipped = new[] { 1, 2 }.EquiZip(new[] { 4, 5, 6 }, Tuple.Create); + Assert.That(zipped, Is.Not.Null); + Assert.Throws(() => + zipped.Consume()); + } - [Test] - public void BothSequencesDisposedWithUnequalLengthsAndShorterFirst() - { - using (var longer = TestingSequence.Of(1, 2, 3)) - using (var shorter = TestingSequence.Of(1, 2)) - { - // Yes, this will throw... but then we should still have disposed both sequences - Assert.Throws(() => - shorter.EquiZip(longer, (x, y) => x + y).Consume()); - } - } + [Test] + public void ZipWithFirstSequnceLongerThanSecondFailStrategy() + { + var zipped = new[] { 1, 2, 3 }.EquiZip(new[] { 4, 5 }, Tuple.Create); + Assert.That(zipped, Is.Not.Null); + Assert.Throws(() => + zipped.Consume()); + } - [Test] - public void ZipWithEqualLengthSequencesFailStrategy() - { - var zipped = new[] {1, 2, 3}.EquiZip(new[] {4, 5, 6}, Tuple.Create); - Assert.That(zipped, Is.Not.Null); - zipped.AssertSequenceEqual((1, 4), (2, 5), (3, 6)); - } + [Test] + public void ZipIsLazy() + { + var bs = new BreakingSequence(); + bs.EquiZip(bs, BreakingFunc.Of()); + } - [Test] - public void ZipWithFirstSequenceShorterThanSecondFailStrategy() + [Test] + public void MoveNextIsNotCalledUnnecessarily() + { + using (var s1 = TestingSequence.Of(1, 2)) + using (var s2 = TestingSequence.Of(1, 2, 3)) + using (var s3 = MoreEnumerable.From(() => 1, + () => 2, + () => throw new TestException()) + .AsTestingSequence()) { - var zipped = new[] {1, 2}.EquiZip(new[] {4, 5, 6}, Tuple.Create); - Assert.That(zipped, Is.Not.Null); Assert.Throws(() => - zipped.Consume()); + s1.EquiZip(s2, s3, (x, y, z) => x + y + z).Consume()); } + } - [Test] - public void ZipWithFirstSequnceLongerThanSecondFailStrategy() + [Test] + public void ZipDisposesInnerSequencesCaseGetEnumeratorThrows() + { + using (var s1 = TestingSequence.Of(1, 2)) { - var zipped = new[] {1, 2, 3}.EquiZip(new[] {4, 5}, Tuple.Create); - Assert.That(zipped, Is.Not.Null); Assert.Throws(() => - zipped.Consume()); - } - - [Test] - public void ZipIsLazy() - { - var bs = new BreakingSequence(); - bs.EquiZip(bs, BreakingFunc.Of()); - } - - [Test] - public void MoveNextIsNotCalledUnnecessarily() - { - using (var s1 = TestingSequence.Of(1, 2)) - using (var s2 = TestingSequence.Of(1, 2, 3)) - using (var s3 = MoreEnumerable.From(() => 1, - () => 2, - () => throw new TestException()) - .AsTestingSequence()) - { - Assert.Throws(() => - s1.EquiZip(s2, s3, (x, y, z) => x + y + z).Consume()); - } - } - - [Test] - public void ZipDisposesInnerSequencesCaseGetEnumeratorThrows() - { - using (var s1 = TestingSequence.Of(1, 2)) - { - Assert.Throws(() => - s1.EquiZip(new BreakingSequence(), Tuple.Create).Consume()); - } + s1.EquiZip(new BreakingSequence(), Tuple.Create).Consume()); } } } diff --git a/MoreLinq/EquiZip.cs b/MoreLinq/EquiZip.cs index 21f418cc2..b98547883 100644 --- a/MoreLinq/EquiZip.cs +++ b/MoreLinq/EquiZip.cs @@ -198,10 +198,7 @@ public static IEnumerable EquiZip( public static IEnumerable<(T1, T2)> EquiZip(this IEnumerable first, IEnumerable second) { - if (first == null) throw new ArgumentNullException(nameof(first)); - if (second == null) throw new ArgumentNullException(nameof(second)); - - return EquiZipImpl(first, second, null, null, (a, b, c, d) => ValueTuple.Create(a, b)); + return first.EquiZip(second, ValueTuple.Create); } /// @@ -239,11 +236,7 @@ public static IEnumerable EquiZip( this IEnumerable first, IEnumerable second, IEnumerable third) { - if (first == null) throw new ArgumentNullException(nameof(first)); - if (second == null) throw new ArgumentNullException(nameof(second)); - if (third == null) throw new ArgumentNullException(nameof(third)); - - return EquiZipImpl(first, second, third, null, (a, b, c, d) => ValueTuple.Create(a, b, c)); + return first.EquiZip(second, third, ValueTuple.Create); } /// @@ -284,12 +277,7 @@ public static IEnumerable EquiZip( this IEnumerable first, IEnumerable second, IEnumerable third, IEnumerable fourth) { - if (first == null) throw new ArgumentNullException(nameof(first)); - if (second == null) throw new ArgumentNullException(nameof(second)); - if (third == null) throw new ArgumentNullException(nameof(third)); - if (fourth == null) throw new ArgumentNullException(nameof(fourth)); - - return EquiZipImpl(first, second, third, fourth, ValueTuple.Create); + return first.EquiZip(second, third, fourth, ValueTuple.Create); } static IEnumerable EquiZipImpl( From c1ae03567f965b98fd0a6439a778509862fb6e98 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 11:58:21 +0100 Subject: [PATCH 08/40] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e89818a6..895eb0929 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ Returns a projection of tuples, where each tuple contains the N-th element from each of the argument sequences. An exception is thrown if the input sequences are of different lengths. -This method has 3 overloads. +This method has 6 overloads. ### Exactly From cbe745c55cd8c16c02bc41deaed713a95efa2219 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 31 Oct 2019 13:33:20 +0100 Subject: [PATCH 09/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 106 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06ce18380..e657a6eaf 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1324,6 +1324,73 @@ public static bool EndsWith(this IEnumerable first, IEnumerable second, [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class EquiZipExtension { + + /// + /// Returns tuples, where each tuple contains the N-th + /// element from each of the argument sequences. An exception is thrown + /// if the input sequences are of different lengths. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// The first sequence. + /// The second sequence. + /// + /// A sequence of tuples that contains elements of the two input sequences. + /// + /// + /// The input sequences are of different lengths. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A), + /// (2, B), (3, C), (4, D) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2)> EquiZip(this IEnumerable first, IEnumerable second) + => MoreEnumerable.EquiZip(first, second); + + /// + /// Returns tuples, where each tuple contains the N-th + /// element from each of the argument sequences. An exception is thrown + /// if the input sequences are of different lengths. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// Type of elements in third sequence + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// + /// A sequence of tuples that contains elements of the three input sequences. + /// + /// + /// The input sequences are of different lengths. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A, a), + /// (2, B, b), (3, C, c), (4, D, d) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3)> EquiZip( + this IEnumerable first, + IEnumerable second, IEnumerable third) + => MoreEnumerable.EquiZip(first, second, third); /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. An exception is thrown @@ -1362,6 +1429,45 @@ public static IEnumerable EquiZip( Func resultSelector) => MoreEnumerable.EquiZip(first, second, resultSelector); + /// + /// Returns tuples, where each tuple contains the N-th + /// element from each of the argument sequences. An exception is thrown + /// if the input sequences are of different lengths. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// Type of elements in third sequence + /// Type of elements in fourth sequence + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// The fourth sequence. + /// + /// A sequence of tuples that contains elements of the four input sequences. + /// + /// + /// The input sequences are of different lengths. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A, a, True), + /// (2, B, b, False), (3, C, c, True), (4, D, d, False) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> EquiZip( + this IEnumerable first, + IEnumerable second, IEnumerable third, IEnumerable fourth) + => MoreEnumerable.EquiZip(first, second, third, fourth); + /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. An exception is thrown From 2a5ad8a18a80540453ecb986bb9ac7ac4a6753bf Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 13:58:02 +0100 Subject: [PATCH 10/40] Tuple-returning overload for ZipLongest --- MoreLinq/ZipLongest.cs | 115 +++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/MoreLinq/ZipLongest.cs b/MoreLinq/ZipLongest.cs index ec5a240e6..13084e8e7 100644 --- a/MoreLinq/ZipLongest.cs +++ b/MoreLinq/ZipLongest.cs @@ -165,5 +165,120 @@ public static IEnumerable ZipLongest( return ZipImpl(first, second, third, fourth, resultSelector, 3); } + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// The first sequence. + /// The second sequence. + /// + /// A sequence of tuples that contains elements of the two input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A), + /// (2, B), (3, C), (0, D) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(TFirst, TSecond)> ZipLongest( + this IEnumerable first, + IEnumerable second) + { + return first.ZipLongest(second, ValueTuple.Create); + } + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// Type of elements in third sequence. + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// + /// A sequence of tuples that contains elements of the three input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield (1, "A", 'a'), + /// (2, "B", 'b'), (3, "C", 'c'), (0, "D", 'd'), (0, , 'e') in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3)> ZipLongest( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + { + return first.ZipLongest(second, third, ValueTuple.Create); + } + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// Type of elements in third sequence + /// Type of elements in fourth sequence + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// The fourth sequence. + /// + /// A sequence of tuples that contains elements of the four input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield (1, "A", 'a', ), + /// (2, "B", 'b', ), (3, "C", 'c', ), (0, "D", 'd', ), + /// (0, , 'e', ), (0, , '\0', ) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> ZipLongest( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + { + return first.ZipLongest(second, third, fourth, ValueTuple.Create); + } } } diff --git a/README.md b/README.md index 895eb0929..358cfbdb9 100644 --- a/README.md +++ b/README.md @@ -719,7 +719,7 @@ 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. -This method has 3 overloads. +This method has 6 overloads. ### ZipShortest From c5aba9d46adb3ce6798318c5c10657975f498102 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 31 Oct 2019 15:04:13 +0100 Subject: [PATCH 11/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 109 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index e657a6eaf..06fb99e8e 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -6912,6 +6912,74 @@ public static IEnumerable> WindowRight(this IEnumerable< [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class ZipLongestExtension { + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// The first sequence. + /// The second sequence. + /// + /// A sequence of tuples that contains elements of the two input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield the tuples : (1, A), + /// (2, B), (3, C), (0, D) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(TFirst, TSecond)> ZipLongest( + this IEnumerable first, + IEnumerable second) + => MoreEnumerable.ZipLongest(first, second); + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// Type of elements in third sequence. + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// + /// A sequence of tuples that contains elements of the three input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield (1, "A", 'a'), + /// (2, "B", 'b'), (3, "C", 'c'), (0, "D", 'd'), (0, , 'e') in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3)> ZipLongest( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + => MoreEnumerable.ZipLongest(first, second, third); /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. The resulting sequence @@ -6949,6 +7017,47 @@ public static IEnumerable ZipLongest( Func resultSelector) => MoreEnumerable.ZipLongest(first, second, resultSelector); + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence + /// Type of elements in second sequence + /// Type of elements in third sequence + /// Type of elements in fourth sequence + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// The fourth sequence. + /// + /// A sequence of tuples that contains elements of the four input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield (1, "A", 'a', ), + /// (2, "B", 'b', ), (3, "C", 'c', ), (0, "D", 'd', ), + /// (0, , 'e', ), (0, , '\0', ) in turn. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> ZipLongest( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + => MoreEnumerable.ZipLongest(first, second, third, fourth); + /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. The resulting sequence From d72663430c83fd1b44a226575810de0112917d1d Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 16:24:22 +0100 Subject: [PATCH 12/40] Tuple-returning overload for ZipShortest --- MoreLinq/ZipShortest.cs | 126 ++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/MoreLinq/ZipShortest.cs b/MoreLinq/ZipShortest.cs index 06920e2df..1c51c069b 100644 --- a/MoreLinq/ZipShortest.cs +++ b/MoreLinq/ZipShortest.cs @@ -174,6 +174,132 @@ public static IEnumerable ZipShortest( return ZipImpl(first, second, third, fourth, resultSelector); } + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// The first sequence. + /// The second sequence. + /// + /// A sequence of tuples that contains elements of the two input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield + /// (1, "A"), (2, "B"), (3, "C") in turn. + /// + /// + /// + /// If the input sequences are of different lengths, the result sequence + /// is terminated as soon as the shortest input sequence is exhausted + /// and remainder elements from the longer sequences are never consumed. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(TFirst, TSecond)> ZipShortest( + this IEnumerable first, + IEnumerable second) + { + return first.ZipShortest(second, ValueTuple.Create); + } + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// Type of elements in third sequence. + /// First sequence + /// Second sequence + /// Third sequence + /// + /// A sequence of tuples that contains elements of the three input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield + /// (1, "A", 'a'), (2, "B", 'b'), (3, "C", 'c') in turn. + /// + /// + /// + /// If the input sequences are of different lengths, the result sequence + /// is terminated as soon as the shortest input sequence is exhausted + /// and remainder elements from the longer sequences are never consumed. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3)> ZipShortest( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + { + return first.ZipShortest(second, third, ValueTuple.Create); + } + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// Type of elements in third sequence. + /// Type of elements in fourth sequence. + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// The fourth sequence. + /// + /// A sequence of tuples that contains elements of the four input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield + /// (1, "A", 'a', ), (2, "B", 'b', ) in turn. + /// + /// + /// + /// If the input sequences are of different lengths, the result sequence + /// is terminated as soon as the shortest input sequence is exhausted + /// and remainder elements from the longer sequences are never consumed. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> ZipShortest( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + { + return first.ZipShortest(second, third, fourth, ValueTuple.Create); + } + static IEnumerable ZipImpl( IEnumerable s1, IEnumerable s2, IEnumerable s3, IEnumerable s4, diff --git a/README.md b/README.md index 358cfbdb9..c33612d2e 100644 --- a/README.md +++ b/README.md @@ -727,7 +727,7 @@ 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. -This method has 3 overloads. +This method has 6 overloads. ## Experimental Operators From 8465c2d99f93e517d5867ac59222442facd40252 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 16:48:22 +0100 Subject: [PATCH 13/40] Tuple-returning overload for TagFirstLast --- MoreLinq/TagFirstLast.cs | 29 +++++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 31 insertions(+) diff --git a/MoreLinq/TagFirstLast.cs b/MoreLinq/TagFirstLast.cs index f22d3fbbf..192cecb11 100644 --- a/MoreLinq/TagFirstLast.cs +++ b/MoreLinq/TagFirstLast.cs @@ -63,5 +63,34 @@ public static IEnumerable TagFirstLast(this IEnumerab return source.Index() // count-up .CountDown(1, (e, cd) => resultSelector(e.Value, e.Key == 0, cd == 0)); } + + /// + /// Returns a sequence of tuples, where the N-th tuple contains the N-th + /// element of the source sequence and two booleans indicating whether the + /// element is the first and/or last. + /// + /// The type of the elements of . + /// The source sequence. + /// + /// Returns the resulting sequence. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + /// + /// + /// The result variable, when iterated over, will yield + /// (Value = 123, IsFirst = , IsLast = ), + /// (Value = 456, IsFirst = , IsLast = ) and + /// (Value = 789, IsFirst = , IsLast = ) in turn. + /// + + public static IEnumerable<(TSource Value, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) + { + return TagFirstLast(source, (value, isFirst, isLast) => (value, isFirst, isLast)); + } } } diff --git a/README.md b/README.md index 358cfbdb9..01e789c7f 100644 --- a/README.md +++ b/README.md @@ -591,6 +591,8 @@ Returns a sequence resulting from applying a function to each element in the source sequence with additional parameters indicating whether the element is the first and/or last of the sequence +This method has 2 overloads. + ### TakeEvery Returns every N-th element of a source sequence From 6d183f4ad1d011d8bd6ee2df7988a53de5a6b60a Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 31 Oct 2019 17:12:35 +0100 Subject: [PATCH 14/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 120 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06fb99e8e..1ff07fd71 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -7151,6 +7151,82 @@ public static IEnumerable ZipLongest( [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class ZipShortestExtension { + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// The first sequence. + /// The second sequence. + /// + /// A sequence of tuples that contains elements of the two input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield + /// (1, "A"), (2, "B"), (3, "C") in turn. + /// + /// + /// + /// If the input sequences are of different lengths, the result sequence + /// is terminated as soon as the shortest input sequence is exhausted + /// and remainder elements from the longer sequences are never consumed. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(TFirst, TSecond)> ZipShortest( + this IEnumerable first, + IEnumerable second) + => MoreEnumerable.ZipShortest(first, second); + + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// Type of elements in third sequence. + /// First sequence + /// Second sequence + /// Third sequence + /// + /// A sequence of tuples that contains elements of the three input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield + /// (1, "A", 'a'), (2, "B", 'b'), (3, "C", 'c') in turn. + /// + /// + /// + /// If the input sequences are of different lengths, the result sequence + /// is terminated as soon as the shortest input sequence is exhausted + /// and remainder elements from the longer sequences are never consumed. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3)> ZipShortest( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + => MoreEnumerable.ZipShortest(first, second, third); /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. The resulting sequence @@ -7190,6 +7266,50 @@ public static IEnumerable ZipShortest( Func resultSelector) => MoreEnumerable.ZipShortest(first, second, resultSelector); + /// + /// Returns a sequence 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. + /// + /// Type of elements in first sequence. + /// Type of elements in second sequence. + /// Type of elements in third sequence. + /// Type of elements in fourth sequence. + /// The first sequence. + /// The second sequence. + /// The third sequence. + /// The fourth sequence. + /// + /// A sequence of tuples that contains elements of the four input sequences. + /// + /// + /// + /// The zipped variable, when iterated over, will yield + /// (1, "A", 'a', ), (2, "B", 'b', ) in turn. + /// + /// + /// + /// If the input sequences are of different lengths, the result sequence + /// is terminated as soon as the shortest input sequence is exhausted + /// and remainder elements from the longer sequences are never consumed. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> ZipShortest( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + => MoreEnumerable.ZipShortest(first, second, third, fourth); + /// /// Returns a projection of tuples, where each tuple contains the N-th /// element from each of the argument sequences. The resulting sequence From ea0d47066585b833aad426ff66051d58cf10cb59 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 17:32:14 +0100 Subject: [PATCH 15/40] Tuple-returning overload for Lag --- MoreLinq.Test/MoreLinq.Test.csproj | 4 +--- MoreLinq/Lag.cs | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index 1dc81cafe..d8be94ebb 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -2,15 +2,13 @@ MoreLinq.Test - netcoreapp1.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;net451 + net4.5.1 true portable MoreLinq.Test Exe true false - $(PackageTargetFallback);dotnet5.4;portable-net451+win8 - 1.0.4 false library diff --git a/MoreLinq/Lag.cs b/MoreLinq/Lag.cs index 51cdf5808..e0fd11a87 100644 --- a/MoreLinq/Lag.cs +++ b/MoreLinq/Lag.cs @@ -94,5 +94,40 @@ public static IEnumerable Lag(this IEnumerable + /// Produces a sequence of tuple containing a pair of elements separated by a negative offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ /// For elements prior to the lag offset, default(T) is used as the lagged value.
+ ///
+ /// The type of the elements of the source sequence + /// The sequence over which to evaluate lag + /// The offset (expressed as a positive number) by which to lag each value of the sequence + /// A sequence of element of the sequence with its lagged pairing + + public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset) + { + return Lag(source, offset, default, ValueTuple.Create); + } + + /// + /// Produces a sequence of tuple containing a pair of elements separated by a negative offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ /// For elements prior to the lag offset, is used as the lagged value.
+ ///
+ /// The type of the elements of the source sequence + /// The sequence over which to evaluate lag + /// The offset (expressed as a positive number) by which to lag each value of the sequence + /// A default value supplied for the lagged value prior to the lag offset + /// A sequence of element of the sequence with its lagged pairing + + public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset, TSource defaultLagValue) + { + return Lag(source, offset, defaultLagValue, ValueTuple.Create); + } } } From b189c3364af6a275e45ce76dd08cbd7b5e12625c Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 17:38:31 +0100 Subject: [PATCH 16/40] Update MoreLinq/TagFirstLast.cs Yes it can. Co-Authored-By: Atif Aziz --- MoreLinq/TagFirstLast.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq/TagFirstLast.cs b/MoreLinq/TagFirstLast.cs index 192cecb11..fdbea39a7 100644 --- a/MoreLinq/TagFirstLast.cs +++ b/MoreLinq/TagFirstLast.cs @@ -90,7 +90,7 @@ public static IEnumerable TagFirstLast(this IEnumerab public static IEnumerable<(TSource Value, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) { - return TagFirstLast(source, (value, isFirst, isLast) => (value, isFirst, isLast)); + return TagFirstLast(source, ValueTuple.Create); } } } From b78bdd24658f98955510ffa5ebc01521f42993e0 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 17:51:34 +0100 Subject: [PATCH 17/40] Fix comments --- MoreLinq/TagFirstLast.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MoreLinq/TagFirstLast.cs b/MoreLinq/TagFirstLast.cs index fdbea39a7..47881ebc3 100644 --- a/MoreLinq/TagFirstLast.cs +++ b/MoreLinq/TagFirstLast.cs @@ -83,12 +83,12 @@ public static IEnumerable TagFirstLast(this IEnumerab /// var result = numbers.TagFirstLast(); /// ]]> /// The result variable, when iterated over, will yield - /// (Value = 123, IsFirst = , IsLast = ), - /// (Value = 456, IsFirst = , IsLast = ) and - /// (Value = 789, IsFirst = , IsLast = ) in turn. + /// (123, , ), + /// (456, , ) and + /// (789, , ) in turn. /// - public static IEnumerable<(TSource Value, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) + public static IEnumerable<(TSource Item, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) { return TagFirstLast(source, ValueTuple.Create); } From 003e298c76ef1901c086e380014f606dbc41ad62 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 17:54:44 +0100 Subject: [PATCH 18/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06fb99e8e..dc7c6fab0 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -5731,6 +5731,33 @@ public static IEnumerable> Subsets(this IEnumerable sequence, int [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class TagFirstLastExtension { + + /// + /// Returns a sequence of tuples, where the N-th tuple contains the N-th + /// element of the source sequence and two booleans indicating whether the + /// element is the first and/or last. + /// + /// The type of the elements of . + /// The source sequence. + /// + /// Returns the resulting sequence. + /// + /// + /// This operator uses deferred execution and streams its results. + /// + /// + /// + /// The result variable, when iterated over, will yield + /// (123, , ), + /// (456, , ) and + /// (789, , ) in turn. + /// + + public static IEnumerable<(TSource Item, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) + => MoreEnumerable.TagFirstLast(source); /// /// Returns a sequence resulting from applying a function to each /// element in the source sequence with additional parameters From 5639dd8578ee6571fb96799d45d3ff11b21e9d0a Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 17:57:23 +0100 Subject: [PATCH 19/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06fb99e8e..90a780467 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -3105,6 +3105,37 @@ public static IEnumerable Interleave(this IEnumerable sequence, params [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class LagExtension { + + /// + /// Produces a sequence of tuple containing a pair of elements separated by a negative offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ /// For elements prior to the lag offset, default(T) is used as the lagged value.
+ ///
+ /// The type of the elements of the source sequence + /// The sequence over which to evaluate lag + /// The offset (expressed as a positive number) by which to lag each value of the sequence + /// A sequence of element of the sequence with its lagged pairing + + public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset) + => MoreEnumerable.Lag(source, offset); + + /// + /// Produces a sequence of tuple containing a pair of elements separated by a negative offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ /// For elements prior to the lag offset, is used as the lagged value.
+ ///
+ /// The type of the elements of the source sequence + /// The sequence over which to evaluate lag + /// The offset (expressed as a positive number) by which to lag each value of the sequence + /// A default value supplied for the lagged value prior to the lag offset + /// A sequence of element of the sequence with its lagged pairing + + public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset, TSource defaultLagValue) + => MoreEnumerable.Lag(source, offset, defaultLagValue); /// /// Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset. /// From 5035b57fcd02b44ef474209266c4888e35cfde60 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 18:02:16 +0100 Subject: [PATCH 20/40] Revert changes on MoreLinq.Test.csproj --- MoreLinq.Test/MoreLinq.Test.csproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index d8be94ebb..1dc81cafe 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -2,13 +2,15 @@ MoreLinq.Test - net4.5.1 + netcoreapp1.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;net451 true portable MoreLinq.Test Exe true false + $(PackageTargetFallback);dotnet5.4;portable-net451+win8 + 1.0.4 false library From fac31888581a27c43840c68b2c2b654b670f4207 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 18:10:50 +0100 Subject: [PATCH 21/40] Fix comment (again) --- MoreLinq/TagFirstLast.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MoreLinq/TagFirstLast.cs b/MoreLinq/TagFirstLast.cs index 47881ebc3..479684307 100644 --- a/MoreLinq/TagFirstLast.cs +++ b/MoreLinq/TagFirstLast.cs @@ -83,9 +83,9 @@ public static IEnumerable TagFirstLast(this IEnumerab /// var result = numbers.TagFirstLast(); /// ]]> /// The result variable, when iterated over, will yield - /// (123, , ), - /// (456, , ) and - /// (789, , ) in turn. + /// (123, True, False), + /// (456, False, False) and + /// (789, False, True) in turn. /// public static IEnumerable<(TSource Item, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) From 1f77a7f43be4f491cf8a0f5e2c540a27ded44d0f Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 31 Oct 2019 18:13:56 +0100 Subject: [PATCH 22/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index dc7c6fab0..3de12a4b5 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -5751,9 +5751,9 @@ public static partial class TagFirstLastExtension /// var result = numbers.TagFirstLast(); /// ]]> /// The result variable, when iterated over, will yield - /// (123, , ), - /// (456, , ) and - /// (789, , ) in turn. + /// (123, True, False), + /// (456, False, False) and + /// (789, False, True) in turn. /// public static IEnumerable<(TSource Item, bool IsFirst, bool IsLast)> TagFirstLast(this IEnumerable source) From d902195cacaada9f71c8575f56b5d21ca3ae0b90 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 31 Oct 2019 18:42:31 +0100 Subject: [PATCH 23/40] Re-format comment --- MoreLinq/Extensions.g.cs | 3 +-- MoreLinq/TagFirstLast.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 3de12a4b5..c5cbd81f2 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -5751,8 +5751,7 @@ public static partial class TagFirstLastExtension /// var result = numbers.TagFirstLast(); /// ]]> /// The result variable, when iterated over, will yield - /// (123, True, False), - /// (456, False, False) and + /// (123, True, False), (456, False, False) and /// (789, False, True) in turn. /// diff --git a/MoreLinq/TagFirstLast.cs b/MoreLinq/TagFirstLast.cs index 479684307..2bc820beb 100644 --- a/MoreLinq/TagFirstLast.cs +++ b/MoreLinq/TagFirstLast.cs @@ -83,8 +83,7 @@ public static IEnumerable TagFirstLast(this IEnumerab /// var result = numbers.TagFirstLast(); /// ]]> /// The result variable, when iterated over, will yield - /// (123, True, False), - /// (456, False, False) and + /// (123, True, False), (456, False, False) and /// (789, False, True) in turn. /// From 93ad6beb6f8fb01cc3562ea6cee1c1197571595d Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 08:50:37 +0100 Subject: [PATCH 24/40] Update README Improve ValueTuple property name returned by Lag --- MoreLinq/Lag.cs | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MoreLinq/Lag.cs b/MoreLinq/Lag.cs index e0fd11a87..49d5a308e 100644 --- a/MoreLinq/Lag.cs +++ b/MoreLinq/Lag.cs @@ -107,7 +107,7 @@ public static IEnumerable Lag(this IEnumerableThe offset (expressed as a positive number) by which to lag each value of the sequence /// A sequence of element of the sequence with its lagged pairing - public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset) + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lag(this IEnumerable source, int offset) { return Lag(source, offset, default, ValueTuple.Create); } @@ -125,7 +125,7 @@ public static IEnumerable Lag(this IEnumerableA default value supplied for the lagged value prior to the lag offset /// A sequence of element of the sequence with its lagged pairing - public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset, TSource defaultLagValue) + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lag(this IEnumerable source, int offset, TSource defaultLagValue) { return Lag(source, offset, defaultLagValue, ValueTuple.Create); } diff --git a/README.md b/README.md index 358cfbdb9..fe4142922 100644 --- a/README.md +++ b/README.md @@ -349,7 +349,7 @@ This method has 2 overloads. Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset. -This method has 2 overloads. +This method has 4 overloads. ### Lead From d12739874c5dbda2fa7d458f105fc523932bab46 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 08:58:24 +0100 Subject: [PATCH 25/40] sourve enumerator wasn't disposed in Lead implementation. --- MoreLinq/Lead.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq/Lead.cs b/MoreLinq/Lead.cs index dc5a9c391..a354aea30 100644 --- a/MoreLinq/Lead.cs +++ b/MoreLinq/Lead.cs @@ -65,7 +65,7 @@ public static IEnumerable Lead(this IEnumerable _() { var leadQueue = new Queue(offset); - var iter = source.GetEnumerator(); + using var iter = source.GetEnumerator(); bool hasMore; // first, prefetch and populate the lead queue with the next step of From 79db9ad31e60fee6913e8f9d0afbc566fff74b90 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 09:01:13 +0100 Subject: [PATCH 26/40] Refresh wrapper extensions --- MoreLinq/Extensions.g.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 90a780467..b7f11ec9f 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -3118,7 +3118,7 @@ public static partial class LagExtension /// The offset (expressed as a positive number) by which to lag each value of the sequence /// A sequence of element of the sequence with its lagged pairing - public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset) + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lag(this IEnumerable source, int offset) => MoreEnumerable.Lag(source, offset); /// @@ -3134,7 +3134,7 @@ public static partial class LagExtension /// A default value supplied for the lagged value prior to the lag offset /// A sequence of element of the sequence with its lagged pairing - public static IEnumerable<(TSource Current, TSource Lagged)> Lag(this IEnumerable source, int offset, TSource defaultLagValue) + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lag(this IEnumerable source, int offset, TSource defaultLagValue) => MoreEnumerable.Lag(source, offset, defaultLagValue); /// /// Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset. From 39c4014f3f7fd63e45764d87d5871e2901053988 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 09:13:16 +0100 Subject: [PATCH 27/40] Add ValueTuple overload for Lead. --- MoreLinq/Extensions.g.cs | 31 +++++++++++++++++++++++++++++++ MoreLinq/Lead.cs | 35 +++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06fb99e8e..8c014d937 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -3192,6 +3192,37 @@ public static T LastOrDefault(this IExtremaEnumerable source) [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class LeadExtension { + + /// + /// Produces a sequence of tuple containing a pair of elements separated by a positive offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ /// For elements of the sequence that are less than items from the end, + /// default(T) is used as the lead value.
+ ///
+ /// The type of the elements in the source sequence + /// The sequence over which to evaluate Lead + /// The offset (expressed as a positive number) by which to lead each element of the sequence + /// The produced sequence of tuple + + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead(this IEnumerable source, int offset) + => MoreEnumerable.Lead(source, offset); + + /// + /// Produces a sequence of tuple containing a pair of elements separated by a positive offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ ///
+ /// The type of the elements in the source sequence + /// The sequence over which to evaluate Lead + /// The offset (expressed as a positive number) by which to lead each element of the sequence + /// A default value supplied for the leading element when none is available + /// The produced sequence of tuple + + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead(this IEnumerable source, int offset, TSource defaultLeadValue) + => MoreEnumerable.Lead(source, offset, defaultLeadValue); /// /// Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset. /// diff --git a/MoreLinq/Lead.cs b/MoreLinq/Lead.cs index a354aea30..e2095878d 100644 --- a/MoreLinq/Lead.cs +++ b/MoreLinq/Lead.cs @@ -85,5 +85,40 @@ public static IEnumerable Lead(this IEnumerable + /// Produces a sequence of tuple containing a pair of elements separated by a positive offset. + ///
+ /// + /// This operator evaluates in a deferred and streaming manner.
+ /// For elements of the sequence that are less than items from the end, + /// default(T) is used as the lead value.
+ ///
+ /// The type of the elements in the source sequence + /// The sequence over which to evaluate Lead + /// The offset (expressed as a positive number) by which to lead each element of the sequence + /// The produced sequence of tuple + + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead(this IEnumerable source, int offset) + { + return Lead(source, offset, default, ValueTuple.Create); + } + + /// + /// Produces a sequence of tuple containing a pair of elements separated by a positive offset. + /// + /// + /// This operator evaluates in a deferred and streaming manner.
+ ///
+ /// The type of the elements in the source sequence + /// The sequence over which to evaluate Lead + /// The offset (expressed as a positive number) by which to lead each element of the sequence + /// A default value supplied for the leading element when none is available + /// The produced sequence of tuple + + public static IEnumerable<(TSource Item, TSource OffsetItem)> Lead(this IEnumerable source, int offset, TSource defaultLeadValue) + { + return Lead(source, offset, default, ValueTuple.Create); + } } } diff --git a/README.md b/README.md index 358cfbdb9..532973b4c 100644 --- a/README.md +++ b/README.md @@ -356,7 +356,7 @@ This method has 2 overloads. Produces a projection of a sequence by evaluating pairs of elements separated by a positive offset. -This method has 2 overloads. +This method has 4 overloads. ### LeftJoin From efa6e282efa7954f4179eece0a767de2ff8c815f Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 09:23:56 +0100 Subject: [PATCH 28/40] Tuple-returning overload for CountDown --- MoreLinq/CountDown.cs | 40 +++++++++++++++++++++++++++++++++------- MoreLinq/Extensions.g.cs | 26 +++++++++++++++++++++++++- README.md | 2 ++ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/MoreLinq/CountDown.cs b/MoreLinq/CountDown.cs index 94dd43675..ef972812b 100644 --- a/MoreLinq/CountDown.cs +++ b/MoreLinq/CountDown.cs @@ -39,7 +39,7 @@ static partial class MoreEnumerable /// A function that receives the element and the current countdown /// value for the element and which returns those mapped to a /// result returned in the resulting sequence. For elements before - /// the last , the coundown value is + /// the last , the countdown value is /// null. /// /// A sequence of results returned by @@ -58,10 +58,10 @@ public static IEnumerable CountDown(this IEnumerable sou if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); return source.TryAsListLike() is IListLike listLike - ? IterateList(listLike) - : source.TryGetCollectionCount() is int collectionCount - ? IterateCollection(collectionCount) - : IterateSequence(); + ? IterateList(listLike) + : source.TryGetCollectionCount() is int collectionCount + ? IterateCollection(collectionCount) + : IterateSequence(); IEnumerable IterateList(IListLike list) { @@ -70,8 +70,8 @@ IEnumerable IterateList(IListLike list) for (var i = 0; i < list.Count; i++) { var cd = list.Count - i <= count - ? --countdown - : (int?) null; + ? --countdown + : (int?) null; yield return resultSelector(list[i], cd); } } @@ -97,5 +97,31 @@ IEnumerable IterateSequence() yield return resultSelector(queue.Dequeue(), queue.Count); } } + + /// + /// Provides a countdown counter for a given count of elements at the + /// tail of the sequence where zero always represents the last element, + /// one represents the second-last element, two represents the + /// third-last element and so on. + /// + /// + /// The type of elements of + /// The source sequence. + /// Count of tail elements of to count down. + /// + /// A sequence of tuple containing elements from and their countdown. + /// For elements before the last , the countdown value is null. + /// + /// + /// This method uses deferred execution semantics and streams its + /// results. At most, elements of the source + /// sequence may be buffered at any one time unless + /// is a collection or a list. + /// + + public static IEnumerable<(T Item, int? CountDown)> CountDown(this IEnumerable source, int count) + { + return source.CountDown(count, ValueTuple.Create); + } } } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06fb99e8e..265d4653b 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1184,6 +1184,30 @@ public static IEnumerable> CountBy(this I [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] public static partial class CountDownExtension { + + /// + /// Provides a countdown counter for a given count of elements at the + /// tail of the sequence where zero always represents the last element, + /// one represents the second-last element, two represents the + /// third-last element and so on. + /// + /// + /// The type of elements of + /// The source sequence. + /// Count of tail elements of to count down. + /// + /// A sequence of tuple containing elements from and their countdown. + /// For elements before the last , the countdown value is null. + /// + /// + /// This method uses deferred execution semantics and streams its + /// results. At most, elements of the source + /// sequence may be buffered at any one time unless + /// is a collection or a list. + /// + + public static IEnumerable<(T Item, int? CountDown)> CountDown(this IEnumerable source, int count) + => MoreEnumerable.CountDown(source, count); /// /// Provides a countdown counter for a given count of elements at the /// tail of the sequence where zero always represents the last element, @@ -1201,7 +1225,7 @@ public static partial class CountDownExtension /// A function that receives the element and the current countdown /// value for the element and which returns those mapped to a /// result returned in the resulting sequence. For elements before - /// the last , the coundown value is + /// the last , the countdown value is /// null. /// /// A sequence of results returned by diff --git a/README.md b/README.md index 358cfbdb9..131729135 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,8 @@ Provides a countdown counter for a given count of elements at the tail of the sequence where zero always represents the last element, one represents the second-last element, two represents the third-last element and so on. +This method has 2 overloads. + ### DistinctBy Returns all distinct elements of the given source, where "distinctness" is From de9197e46566ba94d139838e9fa08979749e2b41 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 11:51:31 +0100 Subject: [PATCH 29/40] Tuple-returning overload for Cartesian --- MoreLinq/Cartesian.g.cs | 245 +++++++++++++++++++++++++++++++++++++++ MoreLinq/Cartesian.g.tt | 33 +++++- MoreLinq/Extensions.g.cs | 231 ++++++++++++++++++++++++++++++++++++ README.md | 2 +- 4 files changed, 508 insertions(+), 3 deletions(-) diff --git a/MoreLinq/Cartesian.g.cs b/MoreLinq/Cartesian.g.cs index cc8658318..062684ad9 100644 --- a/MoreLinq/Cartesian.g.cs +++ b/MoreLinq/Cartesian.g.cs @@ -72,6 +72,32 @@ public static IEnumerable Cartesian( } } + /// + /// Returns the Cartesian product of two sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2)> Cartesian( + this IEnumerable first, + IEnumerable second) + { + return Cartesian(first, second); + } + /// /// Returns the Cartesian product of three sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -129,6 +155,35 @@ public static IEnumerable Cartesian( } } + /// + /// Returns the Cartesian product of three sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + { + return Cartesian(first, second, third); + } + /// /// Returns the Cartesian product of four sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -194,6 +249,38 @@ public static IEnumerable Cartesian( } } + /// + /// Returns the Cartesian product of four sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + { + return Cartesian(first, second, third, fourth); + } + /// /// Returns the Cartesian product of five sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -267,6 +354,41 @@ public static IEnumerable Cartesian( } } + /// + /// Returns the Cartesian product of five sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth) + { + return Cartesian(first, second, third, fourth, fifth); + } + /// /// Returns the Cartesian product of six sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -348,6 +470,44 @@ public static IEnumerable Cartesian( } } + /// + /// Returns the Cartesian product of six sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// The sixth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5, T6)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth) + { + return Cartesian(first, second, third, fourth, fifth, sixth); + } + /// /// Returns the Cartesian product of seven sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -437,6 +597,47 @@ public static IEnumerable Cartesian + /// Returns the Cartesian product of seven sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// The sixth sequence of elements. + /// The seventh sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh) + { + return Cartesian(first, second, third, fourth, fifth, sixth, seventh); + } + /// /// Returns the Cartesian product of eight sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -533,5 +734,49 @@ public static IEnumerable Cartesian + /// Returns the Cartesian product of eight sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// The sixth sequence of elements. + /// The seventh sequence of elements. + /// The eighth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh, + IEnumerable eighth) + { + return Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth); + } } } diff --git a/MoreLinq/Cartesian.g.tt b/MoreLinq/Cartesian.g.tt index c57605da0..6d2450d47 100644 --- a/MoreLinq/Cartesian.g.tt +++ b/MoreLinq/Cartesian.g.tt @@ -60,6 +60,7 @@ namespace MoreLinq Arguments = args.Take(a.Count) .Select(aa => new { aa.Number, aa.Ordinal }) .ToList(), + TypeParams = string.Join(", ", Enumerable.Range(1, a.Count).Select(i => $"T{i}")) }; foreach (var o in overloads) @@ -93,13 +94,13 @@ namespace MoreLinq /// This method uses deferred execution and stream its results. /// - public static IEnumerable Cartesian<<#= string.Join(", ", from x in o.Arguments select "T" + x.Number) #>, TResult>( + public static IEnumerable Cartesian<<#=o.TypeParams#>, TResult>( this <# foreach (var arg in o.Arguments) { #> IEnumerable> <#= arg.Ordinal #>, <# } #> -Func<<#= string.Join(", ", from x in o.Arguments select "T" + x.Number) #>, TResult> resultSelector) +Func<<#=o.TypeParams#>, TResult> resultSelector) { <# foreach (var arg in o.Arguments) { #> if (<#= arg.Ordinal #> == null) throw new ArgumentNullException(nameof(<#= arg.Ordinal #>)); @@ -124,6 +125,34 @@ Func<<#= string.Join(", ", from x in o.Arguments select "T" + x.Number) #>, TRes } } } + + /// + /// Returns the Cartesian product of <#= o.Arity #> sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// +<# foreach (var arg in o.Arguments) { #> + /// The type of the elements of . +<# } #> +<# foreach (var arg in o.Arguments) {#> + /// The <#= arg.Ordinal #> sequence of elements. +<# } #> + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(<#=o.TypeParams#>)> Cartesian<<#=o.TypeParams#>>( + this <#=string.Join($",{Environment.NewLine} ", from arg in o.Arguments select + $"IEnumerable {arg.Ordinal}")#>) + { + return Cartesian(<#= string.Join(", ", o.Arguments.Select(a => a.Ordinal)) #>); + } <# } #> } } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 06fb99e8e..12503f653 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -706,6 +706,57 @@ public static IEnumerable Batch(this IEnumerable + /// Returns the Cartesian product of two sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2)> Cartesian( + this IEnumerable first, + IEnumerable second) + => MoreEnumerable.Cartesian(first, second); + + /// + /// Returns the Cartesian product of three sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + => MoreEnumerable.Cartesian(first, second, third); /// /// Returns the Cartesian product of two sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -739,6 +790,36 @@ public static IEnumerable Cartesian( Func resultSelector) => MoreEnumerable.Cartesian(first, second, resultSelector); + /// + /// Returns the Cartesian product of four sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + => MoreEnumerable.Cartesian(first, second, third, fourth); + /// /// Returns the Cartesian product of three sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -776,6 +857,39 @@ public static IEnumerable Cartesian( Func resultSelector) => MoreEnumerable.Cartesian(first, second, third, resultSelector); + /// + /// Returns the Cartesian product of five sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth) + => MoreEnumerable.Cartesian(first, second, third, fourth, fifth); + /// /// Returns the Cartesian product of four sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -817,6 +931,42 @@ public static IEnumerable Cartesian( Func resultSelector) => MoreEnumerable.Cartesian(first, second, third, fourth, resultSelector); + /// + /// Returns the Cartesian product of six sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// The sixth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5, T6)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth) + => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth); + /// /// Returns the Cartesian product of five sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -862,6 +1012,45 @@ public static IEnumerable Cartesian( Func resultSelector) => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, resultSelector); + /// + /// Returns the Cartesian product of seven sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// The sixth sequence of elements. + /// The seventh sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh) + => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth, seventh); + /// /// Returns the Cartesian product of six sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -911,6 +1100,48 @@ public static IEnumerable Cartesian( Func resultSelector) => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth, resultSelector); + /// + /// Returns the Cartesian product of eight sequences by enumerating tuples + /// of all possible combinations of one item from each sequence. + /// + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The type of the elements of . + /// The first sequence of elements. + /// The second sequence of elements. + /// The third sequence of elements. + /// The fourth sequence of elements. + /// The fifth sequence of elements. + /// The sixth sequence of elements. + /// The seventh sequence of elements. + /// The eighth sequence of elements. + /// A sequence of tuples. + /// + /// + /// The method returns items in the same order as a nested foreach + /// loop, but all sequences except for are + /// cached when iterated over. The cache is then re-used for any + /// subsequent iterations. + /// + /// This method uses deferred execution and stream its results. + /// + + public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)> Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh, + IEnumerable eighth) + => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth); + /// /// Returns the Cartesian product of seven sequences by enumerating all /// possible combinations of one item from each sequence, and applying diff --git a/README.md b/README.md index 358cfbdb9..42613ba85 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ Returns the Cartesian product of two or more sequences by combining each element from the sequences and applying a user-defined projection to the set. -This method has 8 overloads. +This method has 16 overloads. ### Choose From 1af06479ca653d2c053b0625e11be00a91612de1 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 11:54:34 +0100 Subject: [PATCH 30/40] Fix tuple-returning overload for Cartesian --- MoreLinq/Cartesian.g.cs | 14 +++++++------- MoreLinq/Cartesian.g.tt | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MoreLinq/Cartesian.g.cs b/MoreLinq/Cartesian.g.cs index 062684ad9..616f5ee97 100644 --- a/MoreLinq/Cartesian.g.cs +++ b/MoreLinq/Cartesian.g.cs @@ -95,7 +95,7 @@ public static IEnumerable Cartesian( this IEnumerable first, IEnumerable second) { - return Cartesian(first, second); + return Cartesian(first, second, ValueTuple.Create); } /// @@ -181,7 +181,7 @@ public static IEnumerable Cartesian( IEnumerable second, IEnumerable third) { - return Cartesian(first, second, third); + return Cartesian(first, second, third, ValueTuple.Create); } /// @@ -278,7 +278,7 @@ public static IEnumerable Cartesian( IEnumerable third, IEnumerable fourth) { - return Cartesian(first, second, third, fourth); + return Cartesian(first, second, third, fourth, ValueTuple.Create); } /// @@ -386,7 +386,7 @@ public static IEnumerable Cartesian( IEnumerable fourth, IEnumerable fifth) { - return Cartesian(first, second, third, fourth, fifth); + return Cartesian(first, second, third, fourth, fifth, ValueTuple.Create); } /// @@ -505,7 +505,7 @@ public static IEnumerable Cartesian( IEnumerable fifth, IEnumerable sixth) { - return Cartesian(first, second, third, fourth, fifth, sixth); + return Cartesian(first, second, third, fourth, fifth, sixth, ValueTuple.Create); } /// @@ -635,7 +635,7 @@ public static IEnumerable Cartesian sixth, IEnumerable seventh) { - return Cartesian(first, second, third, fourth, fifth, sixth, seventh); + return Cartesian(first, second, third, fourth, fifth, sixth, seventh, ValueTuple.Create); } /// @@ -776,7 +776,7 @@ public static IEnumerable Cartesian seventh, IEnumerable eighth) { - return Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth); + return Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth, ValueTuple.Create); } } } diff --git a/MoreLinq/Cartesian.g.tt b/MoreLinq/Cartesian.g.tt index 6d2450d47..d08a4de5a 100644 --- a/MoreLinq/Cartesian.g.tt +++ b/MoreLinq/Cartesian.g.tt @@ -151,7 +151,7 @@ Func<<#=o.TypeParams#>, TResult> resultSelector) this <#=string.Join($",{Environment.NewLine} ", from arg in o.Arguments select $"IEnumerable {arg.Ordinal}")#>) { - return Cartesian(<#= string.Join(", ", o.Arguments.Select(a => a.Ordinal)) #>); + return Cartesian(<#= string.Join(", ", o.Arguments.Select(a => a.Ordinal)) #>, ValueTuple.Create); } <# } #> } From 1eab72ed39b196387631f50dbea55b7e6c0331a6 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 12:40:06 +0100 Subject: [PATCH 31/40] Fix build --- MoreLinq/Cartesian.g.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq/Cartesian.g.tt b/MoreLinq/Cartesian.g.tt index d08a4de5a..18e703a82 100644 --- a/MoreLinq/Cartesian.g.tt +++ b/MoreLinq/Cartesian.g.tt @@ -148,7 +148,7 @@ Func<<#=o.TypeParams#>, TResult> resultSelector) /// public static IEnumerable<(<#=o.TypeParams#>)> Cartesian<<#=o.TypeParams#>>( - this <#=string.Join($",{Environment.NewLine} ", from arg in o.Arguments select + this <#=string.Join($",\r\n ", from arg in o.Arguments select $"IEnumerable {arg.Ordinal}")#>) { return Cartesian(<#= string.Join(", ", o.Arguments.Select(a => a.Ordinal)) #>, ValueTuple.Create); From 383b45cc919cec13d8cfd1d5d442704f8b3d8ba6 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 12:43:49 +0100 Subject: [PATCH 32/40] Typo --- MoreLinq/CountDown.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MoreLinq/CountDown.cs b/MoreLinq/CountDown.cs index ef972812b..aa40a6948 100644 --- a/MoreLinq/CountDown.cs +++ b/MoreLinq/CountDown.cs @@ -58,10 +58,10 @@ public static IEnumerable CountDown(this IEnumerable sou if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); return source.TryAsListLike() is IListLike listLike - ? IterateList(listLike) - : source.TryGetCollectionCount() is int collectionCount - ? IterateCollection(collectionCount) - : IterateSequence(); + ? IterateList(listLike) + : source.TryGetCollectionCount() is int collectionCount + ? IterateCollection(collectionCount) + : IterateSequence(); IEnumerable IterateList(IListLike list) { @@ -70,8 +70,8 @@ IEnumerable IterateList(IListLike list) for (var i = 0; i < list.Count; i++) { var cd = list.Count - i <= count - ? --countdown - : (int?) null; + ? --countdown + : (int?) null; yield return resultSelector(list[i], cd); } } @@ -109,7 +109,7 @@ IEnumerable IterateSequence() /// The source sequence. /// Count of tail elements of to count down. /// - /// A sequence of tuple containing elements from and their countdown. + /// A sequence of tuple with an element from and its countdown. /// For elements before the last , the countdown value is null. /// /// From e8dd9ba90c26aee523ecc1d19c401a84bce85db7 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 12:45:36 +0100 Subject: [PATCH 33/40] Typo --- MoreLinq/CountDown.cs | 12 ++++++------ MoreLinq/Extensions.g.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MoreLinq/CountDown.cs b/MoreLinq/CountDown.cs index aa40a6948..d651480b4 100644 --- a/MoreLinq/CountDown.cs +++ b/MoreLinq/CountDown.cs @@ -58,10 +58,10 @@ public static IEnumerable CountDown(this IEnumerable sou if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); return source.TryAsListLike() is IListLike listLike - ? IterateList(listLike) - : source.TryGetCollectionCount() is int collectionCount - ? IterateCollection(collectionCount) - : IterateSequence(); + ? IterateList(listLike) + : source.TryGetCollectionCount() is int collectionCount + ? IterateCollection(collectionCount) + : IterateSequence(); IEnumerable IterateList(IListLike list) { @@ -70,8 +70,8 @@ IEnumerable IterateList(IListLike list) for (var i = 0; i < list.Count; i++) { var cd = list.Count - i <= count - ? --countdown - : (int?) null; + ? --countdown + : (int?) null; yield return resultSelector(list[i], cd); } } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 265d4653b..a8651e9ad 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -1196,7 +1196,7 @@ public static partial class CountDownExtension /// The source sequence. /// Count of tail elements of to count down. /// - /// A sequence of tuple containing elements from and their countdown. + /// A sequence of tuple with an element from and its countdown. /// For elements before the last , the countdown value is null. /// /// From 6a9b4a4fc919010fd9fadf6c751cdd0649b9eff8 Mon Sep 17 00:00:00 2001 From: Orace Date: Mon, 4 Nov 2019 12:47:12 +0100 Subject: [PATCH 34/40] Typo again --- MoreLinq/CountDown.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/CountDown.cs b/MoreLinq/CountDown.cs index d651480b4..b5b3bceda 100644 --- a/MoreLinq/CountDown.cs +++ b/MoreLinq/CountDown.cs @@ -60,8 +60,8 @@ public static IEnumerable CountDown(this IEnumerable sou return source.TryAsListLike() is IListLike listLike ? IterateList(listLike) : source.TryGetCollectionCount() is int collectionCount - ? IterateCollection(collectionCount) - : IterateSequence(); + ? IterateCollection(collectionCount) + : IterateSequence(); IEnumerable IterateList(IListLike list) { From 970f87291a5f929751805c64c802b1a658f0ef29 Mon Sep 17 00:00:00 2001 From: Orace Date: Tue, 5 Nov 2019 15:23:35 +0100 Subject: [PATCH 35/40] There is 14 overload of the Cartesian method. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42613ba85..eabc67af2 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ Returns the Cartesian product of two or more sequences by combining each element from the sequences and applying a user-defined projection to the set. -This method has 16 overloads. +This method has 14 overloads. ### Choose From 3f4cc26bc06e7db71cf5fb868d27aa1274bb9561 Mon Sep 17 00:00:00 2001 From: Orace Date: Fri, 8 Nov 2019 19:54:32 +0100 Subject: [PATCH 36/40] Update MoreLinq/Lead.cs Co-Authored-By: Atif Aziz --- MoreLinq/Lead.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoreLinq/Lead.cs b/MoreLinq/Lead.cs index e2095878d..f7ed1a675 100644 --- a/MoreLinq/Lead.cs +++ b/MoreLinq/Lead.cs @@ -65,7 +65,7 @@ public static IEnumerable Lead(this IEnumerable _() { var leadQueue = new Queue(offset); - using var iter = source.GetEnumerator(); + var iter = source.GetEnumerator(); bool hasMore; // first, prefetch and populate the lead queue with the next step of From ca68c81fdbecdaa89b3aee57bde623c4e82d22d3 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sat, 21 Oct 2023 14:06:31 +0200 Subject: [PATCH 37/40] Sync "Pairwise" overloads tests --- MoreLinq.Test/PairwiseTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MoreLinq.Test/PairwiseTest.cs b/MoreLinq.Test/PairwiseTest.cs index b126e4caa..004538b74 100644 --- a/MoreLinq.Test/PairwiseTest.cs +++ b/MoreLinq.Test/PairwiseTest.cs @@ -43,7 +43,8 @@ public void PairwiseWithSequenceShorterThanTwo(int count) [Test] public void PairwiseWideSourceSequence() { - var result = new[] { "a", "b", "c", "d" }.Pairwise(); + using var source = new[] { "a", "b", "c", "d" }.AsTestingSequence(); + var result = source.Pairwise(); result.AssertSequenceEqual(("a", "b"), ("b", "c"), ("c", "d")); } } From ba17cd609a61f72beead02dfd82662ec485a6419 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 22 Oct 2023 22:48:16 +0200 Subject: [PATCH 38/40] Fix spacing inconsistency in template --- MoreLinq/Cartesian.g.tt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MoreLinq/Cartesian.g.tt b/MoreLinq/Cartesian.g.tt index e8144f1a8..a4444b8a4 100644 --- a/MoreLinq/Cartesian.g.tt +++ b/MoreLinq/Cartesian.g.tt @@ -103,13 +103,13 @@ namespace MoreLinq /// This method uses deferred execution and stream its results. /// - public static IEnumerable Cartesian<<#=o.TypeParams#>, TResult>( + public static IEnumerable Cartesian<<#= o.TypeParams #>, TResult>( this <# foreach (var arg in o.Arguments) { #> IEnumerable> <#= arg.Ordinal #>, <# } #> -Func<<#=o.TypeParams#>, TResult> resultSelector) +Func<<#= o.TypeParams #>, TResult> resultSelector) { <# foreach (var arg in o.Arguments) { #> if (<#= arg.Ordinal #> == null) throw new ArgumentNullException(nameof(<#= arg.Ordinal #>)); @@ -156,9 +156,9 @@ Func<<#=o.TypeParams#>, TResult> resultSelector) /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(<#=o.TypeParams#>)> Cartesian<<#=o.TypeParams#>>( - this <#=string.Join($",\r\n ", from arg in o.Arguments select - $"IEnumerable {arg.Ordinal}")#>) + public static IEnumerable<(<#= o.TypeParams #>)> Cartesian<<#= o.TypeParams #>>( + this <#= string.Join($",\r\n ", from arg in o.Arguments select + $"IEnumerable {arg.Ordinal}") #>) { return Cartesian(<#= string.Join(", ", o.Arguments.Select(a => a.Ordinal)) #>, ValueTuple.Create); } From ca50d61904c42199906d5e57b84af170f8983040 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 22 Oct 2023 23:06:12 +0200 Subject: [PATCH 39/40] Review template queries --- MoreLinq/Cartesian.g.tt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MoreLinq/Cartesian.g.tt b/MoreLinq/Cartesian.g.tt index a4444b8a4..07a7c8e5f 100644 --- a/MoreLinq/Cartesian.g.tt +++ b/MoreLinq/Cartesian.g.tt @@ -69,7 +69,7 @@ namespace MoreLinq Arguments = args.Take(a.Count) .Select(aa => new { aa.Number, aa.Ordinal }) .ToList(), - TypeParams = string.Join(", ", Enumerable.Range(1, a.Count).Select(i => $"T{i}")) + TypeParams = string.Join(", ", from aa in args.Take(a.Count) select $"T{aa.Number}") }; foreach (var o in overloads) @@ -157,10 +157,11 @@ Func<<#= o.TypeParams #>, TResult> resultSelector) /// public static IEnumerable<(<#= o.TypeParams #>)> Cartesian<<#= o.TypeParams #>>( - this <#= string.Join($",\r\n ", from arg in o.Arguments select - $"IEnumerable {arg.Ordinal}") #>) + this <#= string.Join($",{Environment.NewLine} ", + from arg in o.Arguments + select $"IEnumerable {arg.Ordinal}") #>) { - return Cartesian(<#= string.Join(", ", o.Arguments.Select(a => a.Ordinal)) #>, ValueTuple.Create); + return Cartesian(<#= string.Join(", ", from a in o.Arguments select a.Ordinal) #>, ValueTuple.Create); } <# } #> } From 8133e04406c0acdea0c35a905790191e87ddf7e1 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Sun, 22 Oct 2023 23:16:17 +0200 Subject: [PATCH 40/40] Name tuple elements using ordinals --- MoreLinq/Cartesian.g.cs | 91 ++++++++------- MoreLinq/Cartesian.g.tt | 50 ++++----- MoreLinq/Extensions.g.cs | 105 ++++++++++-------- .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 28 ++--- .../netstandard2.0/PublicAPI.Unshipped.txt | 28 ++--- .../netstandard2.1/PublicAPI.Unshipped.txt | 28 ++--- 6 files changed, 172 insertions(+), 158 deletions(-) diff --git a/MoreLinq/Cartesian.g.cs b/MoreLinq/Cartesian.g.cs index ea0fa47e4..23c094d39 100644 --- a/MoreLinq/Cartesian.g.cs +++ b/MoreLinq/Cartesian.g.cs @@ -101,9 +101,10 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2)> Cartesian( - this IEnumerable first, - IEnumerable second) + public static IEnumerable<(T1 First, T2 Second)> + Cartesian( + this IEnumerable first, + IEnumerable second) { return Cartesian(first, second, ValueTuple.Create); } @@ -186,10 +187,11 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third) + public static IEnumerable<(T1 First, T2 Second, T3 Third)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third) { return Cartesian(first, second, third, ValueTuple.Create); } @@ -282,11 +284,12 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth) + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) { return Cartesian(first, second, third, fourth, ValueTuple.Create); } @@ -389,12 +392,13 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4, T5)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth) + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth) { return Cartesian(first, second, third, fourth, fifth, ValueTuple.Create); } @@ -507,13 +511,14 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4, T5, T6)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth, - IEnumerable sixth) + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth) { return Cartesian(first, second, third, fourth, fifth, sixth, ValueTuple.Create); } @@ -636,14 +641,15 @@ public static IEnumerable Cartesian /// - public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth, - IEnumerable sixth, - IEnumerable seventh) + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh) { return Cartesian(first, second, third, fourth, fifth, sixth, seventh, ValueTuple.Create); } @@ -776,15 +782,16 @@ public static IEnumerable Cartesian /// - public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth, - IEnumerable sixth, - IEnumerable seventh, - IEnumerable eighth) + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh, + IEnumerable eighth) { return Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth, ValueTuple.Create); } diff --git a/MoreLinq/Cartesian.g.tt b/MoreLinq/Cartesian.g.tt index 07a7c8e5f..b6ebf8510 100644 --- a/MoreLinq/Cartesian.g.tt +++ b/MoreLinq/Cartesian.g.tt @@ -43,19 +43,20 @@ namespace MoreLinq { new[] { - new { Ordinal = "first" , Arity = "one" }, - new { Ordinal = "second" , Arity = "two" }, - new { Ordinal = "third" , Arity = "three" }, - new { Ordinal = "fourth" , Arity = "four" }, - new { Ordinal = "fifth" , Arity = "five" }, - new { Ordinal = "sixth" , Arity = "six" }, - new { Ordinal = "seventh", Arity = "seven" }, - new { Ordinal = "eighth" , Arity = "eight" }, + new { Ordinal = "First" , Arity = "one" }, + new { Ordinal = "Second" , Arity = "two" }, + new { Ordinal = "Third" , Arity = "three" }, + new { Ordinal = "Fourth" , Arity = "four" }, + new { Ordinal = "Fifth" , Arity = "five" }, + new { Ordinal = "Sixth" , Arity = "six" }, + new { Ordinal = "Seventh", Arity = "seven" }, + new { Ordinal = "Eighth" , Arity = "eight" }, } } select args.Select((a, i) => new { a.Ordinal, + OrdinalLower = a.Ordinal.ToLowerInvariant(), a.Arity, Count = i + 1, Number = (i + 1).ToString(CultureInfo.InvariantCulture), @@ -66,9 +67,7 @@ namespace MoreLinq select new { a.Arity, - Arguments = args.Take(a.Count) - .Select(aa => new { aa.Number, aa.Ordinal }) - .ToList(), + Arguments = args.Take(a.Count).ToList(), TypeParams = string.Join(", ", from aa in args.Take(a.Count) select $"T{aa.Number}") }; @@ -82,12 +81,12 @@ namespace MoreLinq /// <# foreach (var arg in o.Arguments) { #> /// - /// The type of the elements of . + /// The type of the elements of . <# } #> /// /// The type of the elements of the result sequence. <# foreach (var arg in o.Arguments) {#> - /// The <#= arg.Ordinal #> sequence of elements. + /// The <#= arg.OrdinalLower #> sequence of elements. <# } #> /// A projection function that combines /// elements from all of the sequences. @@ -106,29 +105,29 @@ namespace MoreLinq public static IEnumerable Cartesian<<#= o.TypeParams #>, TResult>( this <# foreach (var arg in o.Arguments) { #> -IEnumerable> <#= arg.Ordinal #>, +IEnumerable> <#= arg.OrdinalLower #>, <# } #> Func<<#= o.TypeParams #>, TResult> resultSelector) { <# foreach (var arg in o.Arguments) { #> - if (<#= arg.Ordinal #> == null) throw new ArgumentNullException(nameof(<#= arg.Ordinal #>)); + if (<#= arg.OrdinalLower #> == null) throw new ArgumentNullException(nameof(<#= arg.OrdinalLower #>)); <# } #> if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); return _(); IEnumerable _() { <# foreach (var arg in o.Arguments.Skip(1)) { #> - IEnumerable> <#= arg.Ordinal #>Memo; + IEnumerable> <#= arg.OrdinalLower #>Memo; <# } #> <# foreach (var arg in o.Arguments.Skip(1)) { #> - using ((<#= arg.Ordinal #>Memo = <#= arg.Ordinal #>.Memoize()) as IDisposable) + using ((<#= arg.OrdinalLower #>Memo = <#= arg.OrdinalLower #>.Memoize()) as IDisposable) <# } #> { foreach (var item1 in first) <# foreach (var arg in o.Arguments.Skip(1)) { #> - foreach (var item<#= arg.Number #> in <#= arg.Ordinal #>Memo) + foreach (var item<#= arg.Number #> in <#= arg.OrdinalLower #>Memo) <# } #> yield return resultSelector(<#= string.Join(", ", from x in o.Arguments select "item" + x.Number) #>); } @@ -140,10 +139,10 @@ Func<<#= o.TypeParams #>, TResult> resultSelector) /// of all possible combinations of one item from each sequence. /// <# foreach (var arg in o.Arguments) { #> - /// The type of the elements of . + /// The type of the elements of . <# } #> <# foreach (var arg in o.Arguments) {#> - /// The <#= arg.Ordinal #> sequence of elements. + /// The <#= arg.OrdinalLower #> sequence of elements. <# } #> /// A sequence of tuples. /// @@ -156,12 +155,13 @@ Func<<#= o.TypeParams #>, TResult> resultSelector) /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(<#= o.TypeParams #>)> Cartesian<<#= o.TypeParams #>>( - this <#= string.Join($",{Environment.NewLine} ", - from arg in o.Arguments - select $"IEnumerable {arg.Ordinal}") #>) + public static IEnumerable<(<#= string.Join(", ", from a in o.Arguments select $"T{a.Number} {a.Ordinal}") #>)> + Cartesian<<#= o.TypeParams #>>( + this <#= string.Join($",{Environment.NewLine} ", + from arg in o.Arguments + select $"IEnumerable {arg.OrdinalLower}") #>) { - return Cartesian(<#= string.Join(", ", from a in o.Arguments select a.Ordinal) #>, ValueTuple.Create); + return Cartesian(<#= string.Join(", ", from a in o.Arguments select a.OrdinalLower) #>, ValueTuple.Create); } <# } #> } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index be7a090d1..82bf73c09 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -741,10 +741,11 @@ public static partial class CartesianExtension /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2)> Cartesian( - this IEnumerable first, - IEnumerable second) - => MoreEnumerable.Cartesian(first, second); + public static IEnumerable<(T1 First, T2 Second)> + Cartesian( + this IEnumerable first, + IEnumerable second) + => MoreEnumerable. Cartesian(first, second); /// /// Returns the Cartesian product of three sequences by enumerating tuples @@ -767,11 +768,12 @@ public static partial class CartesianExtension /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third) - => MoreEnumerable.Cartesian(first, second, third); + public static IEnumerable<(T1 First, T2 Second, T3 Third)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third) + => MoreEnumerable. Cartesian(first, second, third); /// /// Returns the Cartesian product of two sequences by enumerating all /// possible combinations of one item from each sequence, and applying @@ -828,12 +830,13 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth) - => MoreEnumerable.Cartesian(first, second, third, fourth); + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth) + => MoreEnumerable. Cartesian(first, second, third, fourth); /// /// Returns the Cartesian product of three sequences by enumerating all @@ -897,13 +900,14 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4, T5)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth) - => MoreEnumerable.Cartesian(first, second, third, fourth, fifth); + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth) + => MoreEnumerable. Cartesian(first, second, third, fourth, fifth); /// /// Returns the Cartesian product of four sequences by enumerating all @@ -973,14 +977,15 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4, T5, T6)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth, - IEnumerable sixth) - => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth); + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth) + => MoreEnumerable. Cartesian(first, second, third, fourth, fifth, sixth); /// /// Returns the Cartesian product of five sequences by enumerating all @@ -1056,15 +1061,16 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth, - IEnumerable sixth, - IEnumerable seventh) - => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth, seventh); + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh) + => MoreEnumerable. Cartesian(first, second, third, fourth, fifth, sixth, seventh); /// /// Returns the Cartesian product of six sequences by enumerating all @@ -1146,16 +1152,17 @@ public static IEnumerable Cartesian( /// This method uses deferred execution and stream its results. /// - public static IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)> Cartesian( - this IEnumerable first, - IEnumerable second, - IEnumerable third, - IEnumerable fourth, - IEnumerable fifth, - IEnumerable sixth, - IEnumerable seventh, - IEnumerable eighth) - => MoreEnumerable.Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth); + public static IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)> + Cartesian( + this IEnumerable first, + IEnumerable second, + IEnumerable third, + IEnumerable fourth, + IEnumerable fifth, + IEnumerable sixth, + IEnumerable seventh, + IEnumerable eighth) + => MoreEnumerable. Cartesian(first, second, third, fourth, fifth, sixth, seventh, eighth); /// /// Returns the Cartesian product of seven sequences by enumerating all diff --git a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt index c09dbf358..5dc34277d 100644 --- a/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -14,13 +14,13 @@ *REMOVED*static MoreLinq.MoreEnumerable.ToHashSet(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.HashSet! static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1, T2)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second)>! static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable<(T Item, int? CountDown)>! static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! @@ -40,13 +40,13 @@ static MoreLinq.Extensions.ZipShortestExtension.ZipShortest(thi static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1, T2)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second)>! static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable<(T Item, int? CountDown)>! static MoreLinq.MoreEnumerable.DistinctBy(System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.DistinctBy(System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.IEnumerable! diff --git a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 5b1a591aa..0ba305d8c 100644 --- a/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -8,13 +8,13 @@ *REMOVED*static MoreLinq.MoreEnumerable.Prepend(this System.Collections.Generic.IEnumerable! source, TSource value) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1, T2)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second)>! static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable<(T Item, int? CountDown)>! static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! @@ -34,13 +34,13 @@ static MoreLinq.Extensions.ZipShortestExtension.ZipShortest(thi static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1, T2)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second)>! static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable<(T Item, int? CountDown)>! static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! diff --git a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index 51da07dc0..c58df9b9c 100644 --- a/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/MoreLinq/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -12,13 +12,13 @@ *REMOVED*static MoreLinq.MoreEnumerable.ToHashSet(this System.Collections.Generic.IEnumerable! source, System.Collections.Generic.IEqualityComparer? comparer) -> System.Collections.Generic.HashSet! static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.Extensions.BatchExtension.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! -static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1, T2)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third)>! +static MoreLinq.Extensions.CartesianExtension.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second)>! static MoreLinq.Extensions.CountDownExtension.CountDown(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable<(T Item, int? CountDown)>! static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! static MoreLinq.Extensions.EquiZipExtension.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! @@ -38,13 +38,13 @@ static MoreLinq.Extensions.ZipShortestExtension.ZipShortest(thi static MoreLinq.MoreEnumerable.Append(System.Collections.Generic.IEnumerable! head, T tail) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size, System.Func! resultSelector) -> System.Collections.Generic.IEnumerable! static MoreLinq.MoreEnumerable.Batch(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7, T8)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6, T7)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5, T6)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4, T5)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>! -static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1, T2)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh, System.Collections.Generic.IEnumerable! eighth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh, T8 Eighth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth, System.Collections.Generic.IEnumerable! seventh) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth, T7 Seventh)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth, System.Collections.Generic.IEnumerable! sixth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth, T6 Sixth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth, System.Collections.Generic.IEnumerable! fifth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth, T5 Fifth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third, T4 Fourth)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second, T3 Third)>! +static MoreLinq.MoreEnumerable.Cartesian(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second) -> System.Collections.Generic.IEnumerable<(T1 First, T2 Second)>! static MoreLinq.MoreEnumerable.CountDown(this System.Collections.Generic.IEnumerable! source, int count) -> System.Collections.Generic.IEnumerable<(T Item, int? CountDown)>! static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third, System.Collections.Generic.IEnumerable! fourth) -> System.Collections.Generic.IEnumerable<(T1, T2, T3, T4)>! static MoreLinq.MoreEnumerable.EquiZip(this System.Collections.Generic.IEnumerable! first, System.Collections.Generic.IEnumerable! second, System.Collections.Generic.IEnumerable! third) -> System.Collections.Generic.IEnumerable<(T1, T2, T3)>!