From 0db7c10e3e05cfbd5b177e3081c1604699ae4667 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 7 Nov 2019 12:39:18 +0100 Subject: [PATCH 1/7] Add BatchBy --- MoreLinq.Test/BatchByTests.cs | 200 ++++ MoreLinq.Test/MoreLinq.Test.csproj | 1 + MoreLinq/BatchBy.cs | 132 +++ MoreLinq/BatchBy.g.cs | 1651 ++++++++++++++++++++++++++++ MoreLinq/BatchBy.g.tt | 270 +++++ MoreLinq/Extensions.g.cs | 1321 ++++++++++++++++++++++ MoreLinq/MoreLinq.csproj | 9 + README.md | 8 + 8 files changed, 3592 insertions(+) create mode 100644 MoreLinq.Test/BatchByTests.cs create mode 100644 MoreLinq/BatchBy.cs create mode 100644 MoreLinq/BatchBy.g.cs create mode 100644 MoreLinq/BatchBy.g.tt diff --git a/MoreLinq.Test/BatchByTests.cs b/MoreLinq.Test/BatchByTests.cs new file mode 100644 index 000000000..727fdab7f --- /dev/null +++ b/MoreLinq.Test/BatchByTests.cs @@ -0,0 +1,200 @@ +using NUnit.Framework.Interfaces; + +namespace MoreLinq.Test +{ + using System; + using System.Collections.Generic; + using NUnit.Framework; + + [TestFixture] + public class BatchByTests + { + public static readonly IEnumerable TestData = + from d in new[] + { + new { + s = new[] {"Q1", "Q2", "A1", "A2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + new { + s = new[] {"Q1", "A1", "Q2", "A2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + new { + s = new[] {"A1", "Q1", "Q2", "A2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + new { + s = new[] {"Q1", "A1", "A2", "Q2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + new { + s = new[] {"A1", "Q1", "A2", "Q2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + new { + s = new[] {"A1", "A2", "Q1", "Q2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + new { + s = new[] {"Q1", null, "A1", "#", "Q2", "A2"}, + k = new[] {"Q", "A"}, + r = new[] { + new [] {("A", "A1"), ("Q", "Q1")}, + new [] {("A", "A2"), ("Q", "Q2")}}}, + } + select new TestCaseData(d.s, d.k).Returns(d.r); + + + [Test, TestCaseSource(nameof(TestData))] + public (string Key, string Value)[][] BatchByOnKnownCase(string[] source, string[] acceptedKeys) + { + static string KeySelector(string s) => s?.FirstOrDefault().ToString(); + var equalityComparer = EqualityComparer.Default; + + return source.BatchBy(acceptedKeys, KeySelector, equalityComparer) + .Select(d => d.Select(kvp => (kvp.Key, kvp.Value)).OrderBy(kvp => kvp.Key).ToArray()) + .ToArray(); + } + + [Test] + public void BatchByDoNotEnumerateSourceOnEmptyAcceptedKeys() + { + var source = MoreEnumerable.From(() => throw new TestException()); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = Enumerable.Empty(); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + } + + Assert.DoesNotThrow(Code); + } + + [Test] + public void BatchByDoNotThrowOnDuplicateAcceptedKeyAtCreation() + { + using var source = TestingSequence.Of(0, 1, 2, 3); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", "1", "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + } + + Assert.DoesNotThrow(Code); + } + + [Test] + public void BatchByDoNotThrowOnNullAcceptedKeyAtCreation() + { + using var source = TestingSequence.Of(0, 1, 2, 3); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", null, "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + } + + Assert.DoesNotThrow(Code); + } + + [Test] + public void BatchByDoNotThrowOnNullKeyFromKeySelector() + { + using var source = TestingSequence.Of(0, 1, 2, 3); + static string KeySelector(int i) => i == 0 ? null : $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", "1", "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + } + + Assert.DoesNotThrow(Code); + } + + [Test] + public void BatchByDoNotThrowOnUnknownKeyFromKeySelector() + { + using var source = TestingSequence.Of(0, 1, 2, 3); + static string KeySelector(int i) => $"#{i}#"; + var acceptedKeys = TestingSequence.Of("0", "1", "1", "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + } + + Assert.DoesNotThrow(Code); + } + + [Test] + public void BatchByIsLazy() + { + var source = new BreakingSequence(); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", "2", "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + } + + Assert.DoesNotThrow(Code); + } + + [Test] + public void BatchByThrowOnDuplicateAcceptedKeyOnFirstIteration() + { + using var source = TestingSequence.Of(0, 1, 2, 3); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", "1", "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer).GetEnumerator().MoveNext(); + } + + Assert.Throws(Code); + } + + [Test] + public void BatchByThrowOnNullAcceptedKeyOnFirstIteration() + { + using var source = TestingSequence.Of(0, 1, 2, 3); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", null, "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + source.BatchBy(acceptedKeys, KeySelector, equalityComparer).GetEnumerator().MoveNext(); + } + + Assert.Throws(Code); + } + } +} diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index 1dc81cafe..be62189b3 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -48,6 +48,7 @@ + diff --git a/MoreLinq/BatchBy.cs b/MoreLinq/BatchBy.cs new file mode 100644 index 000000000..32e84b586 --- /dev/null +++ b/MoreLinq/BatchBy.cs @@ -0,0 +1,132 @@ +#region License and Terms +// MoreLINQ - Extensions to LINQ to Objects +// Copyright (c) 2019 Pierre Lando. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +using System.Linq; + +namespace MoreLinq +{ + using System; + using System.Collections.Generic; + + static partial class MoreEnumerable + { + /// + /// Batch the sequence into buckets that are IDictionary. + /// Each buckets contains all keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the returned buckets. + /// Type of elements in sequence. + /// The source sequence. + /// Sequence of accepted keys. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// The sequence is fully consumed on first iteration. + /// If is empty, is not enumerated. + /// Values from that correspond to a null key are discarded. + /// + /// , , + /// or is null + /// contains null + /// contains duplicate keys relatively to + /// . + public static IEnumerable> BatchBy(this IEnumerable source, + IEnumerable acceptedKeys, + Func keySelector, + IEqualityComparer keyComparer) + { + if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (acceptedKeys == null) throw new ArgumentNullException(nameof(acceptedKeys)); + if (keyComparer == null) throw new ArgumentNullException(nameof(keyComparer)); + + return _(); IEnumerable> _() + { + var queues = acceptedKeys.ToDictionary(k => k, k => new Queue(), keyComparer); + + // early break + if (queues.Count == 0) + yield break; + + var emptyQueueCount = queues.Count; + foreach (var value in source) + { + var key = keySelector(value); + + if (key != null && queues.TryGetValue(key, out var queue)) + { + queue.Enqueue(value); + if (queue.Count == 1) + emptyQueueCount--; + } + + // We need more elements + if (emptyQueueCount > 0) + continue; + + yield return queues.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Dequeue()); + emptyQueueCount = queues.Values.Count(q => q.Count == 0); + } + } + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Each buckets contains all keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the default equality comparer. + /// + /// The type of the keys of the returned buckets. + /// Type of elements in sequence. + /// The source sequence. + /// Sequence of accepted keys. + /// Build the key for elements from the sequence. + /// The build up sequence of buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// The sequence is fully consumed on first iteration. + /// If is empty, is not enumerated. + /// Values from that correspond to a null key are discarded. + /// + /// , or + /// is null + /// contains null + /// contains duplicate keys. + public static IEnumerable> BatchBy(this IEnumerable source, + IEnumerable acceptedKeys, + Func keySelector) + { + return BatchBy(source, acceptedKeys, keySelector, EqualityComparer.Default); + } + } +} diff --git a/MoreLinq/BatchBy.g.cs b/MoreLinq/BatchBy.g.cs new file mode 100644 index 000000000..4760ebd10 --- /dev/null +++ b/MoreLinq/BatchBy.g.cs @@ -0,0 +1,1651 @@ +#region License and Terms +// MoreLINQ - Extensions to LINQ to Objects +// Copyright (c) 2019 Pierre Lando. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +namespace MoreLinq +{ + using System; + using System.Collections.Generic; + using System.Linq; + + static partial class MoreEnumerable + { + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector) + { + return BatchBy(source, + first, + second, + keySelector, ValueTuple.Create); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second], + d[third])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second], + d[third])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + third, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector) + { + return BatchBy(source, + first, + second, + third, + keySelector, ValueTuple.Create); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + third, + fourth, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector) + { + return BatchBy(source, + first, + second, + third, + fourth, + keySelector, ValueTuple.Create); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + keySelector, ValueTuple.Create); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth, + sixth + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth], + d[sixth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth, + sixth + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth], + d[sixth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + sixth, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + sixth, + keySelector, ValueTuple.Create); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth, + sixth, + seventh + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth], + d[sixth], + d[seventh])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth, + sixth, + seventh + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth], + d[sixth], + d[seventh])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + keySelector, ValueTuple.Create); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + eighth + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth], + d[sixth], + d[seventh], + d[eighth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector, + Func resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + eighth + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( + d[first], + d[second], + d[third], + d[fourth], + d[fifth], + d[sixth], + d[seventh], + d[eighth])); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + eighth, + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector) + { + return BatchBy(source, + first, + second, + third, + fourth, + fifth, + sixth, + seventh, + eighth, + keySelector, ValueTuple.Create); + } + + } +} diff --git a/MoreLinq/BatchBy.g.tt b/MoreLinq/BatchBy.g.tt new file mode 100644 index 000000000..168d7d077 --- /dev/null +++ b/MoreLinq/BatchBy.g.tt @@ -0,0 +1,270 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="System.Collections" #> +<#@ import namespace="System.Globalization" #> +<#@ import namespace="System.Linq" #> +#region License and Terms +// MoreLINQ - Extensions to LINQ to Objects +// Copyright (c) 2019 Pierre Lando. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +<# + var ordinals = new[] + { + "", + "first", "second", "third", "fourth", + "fifth", "sixth", "seventh", "eighth" + }; + + var overloads = + Enumerable.Range(2, 7) + .Select(argCount => + Enumerable.Range(1, argCount).Select(argPosition => + new + { + IsFirst = argPosition == 1, + IsLast = argPosition == argCount, + Name = ordinals[argPosition], + Ordinal = ordinals[argPosition], + // Objects associated with the argument + Enumerator = $"e{argPosition}", + Value = $"v{argPosition}" + })) + .Select(args => args.ToList()) + .Select(args => new { Arguments = args }); +#> +namespace MoreLinq +{ + using System; + using System.Collections.Generic; + using System.Linq; + + static partial class MoreEnumerable + { +<# foreach (var o in overloads) + { +#> + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. +<# foreach (var arg in o.Arguments) { #> + /// <#=arg.Ordinal#> key. +<# } #> + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// <# foreach (var arg in o.Arguments) { #>, <# } #> + + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, +<# foreach (var arg in o.Arguments) { #> + TKey <#=arg.Name#>, +<# } #> + Func keySelector, + Func<<# foreach (var arg in o.Arguments) { #>TSource, <#}#>TResult> resultSelector, + IEqualityComparer keyComparer) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { +<# foreach (var arg in o.Arguments) { #> + <#=arg.Name#><#= arg.IsLast ? "" : "," #> +<# } #> + }; + + return BatchBy(source, keys, keySelector, keyComparer) + .Select(d => resultSelector( +<# foreach (var arg in o.Arguments) { #> + d[<#=arg.Name#>]<#= arg.IsLast ? "));" : "," #> +<# } #> + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. +<# foreach (var arg in o.Arguments) { #> + /// <#=arg.Ordinal#> key. +<# } #> + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// <# foreach (var arg in o.Arguments) { #>, <# } #> + + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, +<# foreach (var arg in o.Arguments) { #> + TKey <#=arg.Name#>, +<# } #> + Func keySelector, + Func<<# foreach (var arg in o.Arguments) { #>TSource, <#}#>TResult> resultSelector) + { + if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + + var keys = new [] + { +<# foreach (var arg in o.Arguments) { #> + <#=arg.Name#><#= arg.IsLast ? "" : "," #> +<# } #> + }; + + return BatchBy(source, keys, keySelector) + .Select(d => resultSelector( +<# foreach (var arg in o.Arguments) { #> + d[<#=arg.Name#>]<#= arg.IsLast ? "));" : "," #> +<# } #> + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. +<# foreach (var arg in o.Arguments) { #> + /// <#=arg.Ordinal#> key. +<# } #> + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// <# foreach (var arg in o.Arguments) { #>, <# } #> + + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.Name#><#=arg.IsLast?"":", "#><#}#>)> + BatchBy( + this IEnumerable source, +<# foreach (var arg in o.Arguments) { #> + TKey <#=arg.Name#>, +<# } #> + Func keySelector, + IEqualityComparer keyComparer) + { + return BatchBy(source, +<# foreach (var arg in o.Arguments) { #> + <#=arg.Name#>, +<# } #> + keySelector, ValueTuple.Create, keyComparer); + } + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. +<# foreach (var arg in o.Arguments) { #> + /// <#=arg.Ordinal#> key. +<# } #> + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> + + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.Name#><#=arg.IsLast?"":", "#><#}#>)> + BatchBy( + this IEnumerable source, +<# foreach (var arg in o.Arguments) { #> + TKey <#=arg.Name#>, +<# } #> + Func keySelector) + { + return BatchBy(source, +<# foreach (var arg in o.Arguments) { #> + <#=arg.Name#>, +<# } #> + keySelector, ValueTuple.Create); + } + +<# } #> + } +} diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 0b1211058..440739fdc 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -701,6 +701,1327 @@ public static IEnumerable Batch(this IEnumerableBatchBy extension. + + [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] + public static partial class BatchByExtension + { + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Each buckets contains all keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the default equality comparer. + /// + /// The type of the keys of the returned buckets. + /// Type of elements in sequence. + /// The source sequence. + /// Sequence of accepted keys. + /// Build the key for elements from the sequence. + /// The build up sequence of buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// The sequence is fully consumed on first iteration. + /// If is empty, is not enumerated. + /// Values from that correspond to a null key are discarded. + /// + /// , or + /// is null + /// contains null + /// contains duplicate keys. + public static IEnumerable> BatchBy(this IEnumerable source, + IEnumerable acceptedKeys, + Func keySelector) + => MoreEnumerable.BatchBy(source, acceptedKeys, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, keySelector); + /// + /// Batch the sequence into buckets that are IDictionary. + /// Each buckets contains all keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the returned buckets. + /// Type of elements in sequence. + /// The source sequence. + /// Sequence of accepted keys. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// The sequence is fully consumed on first iteration. + /// If is empty, is not enumerated. + /// Values from that correspond to a null key are discarded. + /// + /// , , + /// or is null + /// contains null + /// contains duplicate keys relatively to + /// . + public static IEnumerable> BatchBy(this IEnumerable source, + IEnumerable acceptedKeys, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, acceptedKeys, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, third, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, third, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , or + /// is null + /// There is some duplicate keys. + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values returned as ValueTuple. + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , , + /// or is null + /// There is some duplicate keys relatively to + + public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector, + IEqualityComparer keyComparer) + => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, keySelector, resultSelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, third, keySelector, resultSelector); + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, keySelector, resultSelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, keySelector, resultSelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, third, keySelector, resultSelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, keySelector, resultSelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, keySelector, resultSelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector, resultSelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, keySelector, resultSelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector, resultSelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector, resultSelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals. + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , , + /// or is null + /// There is some duplicate keys. + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector, + Func resultSelector) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector, resultSelector); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector, resultSelector, keyComparer); + + /// + /// Batch the sequence into buckets that are IDictionary. + /// Then the buckets values are projected with . + /// Each buckets contains all of the given keys and for each of this + /// keys a matching value from the sequence. + /// The matching is done by the . + /// + /// Values from sequence that doesn't have a matching key are discarded. + /// + /// For each key/value pair in a buckets, key and keySelector(value) are equals + /// relatively to the . + /// + /// The type of the keys of the buckets. + /// Type of elements in sequence. + /// Type of the projected value. + /// The source sequence. + /// first key. + /// second key. + /// third key. + /// fourth key. + /// fifth key. + /// sixth key. + /// seventh key. + /// eighth key. + /// Build the key for elements from the sequence. + /// The function used to project the buckets. + /// The comparer used to evaluate keys equality. + /// The build up sequence of projected buckets. + /// + /// This operator uses deferred execution and streams its results. + /// + /// Values from that correspond to a null key are discarded. + /// + /// , + /// , , , , , , , , + /// , or is null + /// There is some duplicate keys relatively to . + + public static IEnumerable BatchBy( + this IEnumerable source, + TKey first, + TKey second, + TKey third, + TKey fourth, + TKey fifth, + TKey sixth, + TKey seventh, + TKey eighth, + Func keySelector, + Func resultSelector, + IEqualityComparer keyComparer) + => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector, resultSelector, keyComparer); + + } + /// Cartesian extension. [GeneratedCode("MoreLinq.ExtensionsGenerator", "1.0.0.0")] diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index dbe55aa50..6824a8660 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -156,6 +156,10 @@ TextTemplatingFileGenerator Aggregate.g.cs + + TextTemplatingFileGenerator + BatchBy.g.cs + TextTemplatingFileGenerator Cartesian.g.cs @@ -208,6 +212,11 @@ True Aggregate.g.tt + + True + True + BatchBy.g.tt + True True diff --git a/README.md b/README.md index 29661bedf..ac881c823 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,14 @@ Batches the source sequence into sized buckets. This method has 2 overloads. +### BatchBy + +Batch by key the source sequence into buckets that are dictionary. +Each buckets contains all accepted keys and for each of this +keys a matching value from the source sequence. + +This method has 30 overloads. + ### Cartesian Returns the Cartesian product of two or more sequences by combining each From 242ad7bb3da0bc67a065ca18092efe77fd92de99 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 7 Nov 2019 12:46:51 +0100 Subject: [PATCH 2/7] Change tuple parameter name to pascal case. --- MoreLinq/BatchBy.g.cs | 308 +++++++++++++++++++-------------------- MoreLinq/BatchBy.g.tt | 41 +++--- MoreLinq/Extensions.g.cs | 308 +++++++++++++++++++-------------------- 3 files changed, 329 insertions(+), 328 deletions(-) diff --git a/MoreLinq/BatchBy.g.cs b/MoreLinq/BatchBy.g.cs index 4760ebd10..3fde328a6 100644 --- a/MoreLinq/BatchBy.g.cs +++ b/MoreLinq/BatchBy.g.cs @@ -39,8 +39,8 @@ static partial class MoreEnumerable /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -92,8 +92,8 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -143,8 +143,8 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -158,7 +158,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second)> + public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, TKey first, @@ -186,8 +186,8 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -200,7 +200,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second)> + public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, TKey first, @@ -229,9 +229,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -286,9 +286,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -341,9 +341,9 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -357,7 +357,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third)> + public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, TKey first, @@ -387,9 +387,9 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -402,7 +402,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third)> + public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, TKey first, @@ -433,10 +433,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -494,10 +494,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -553,10 +553,10 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -570,7 +570,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, TKey first, @@ -602,10 +602,10 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -618,7 +618,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, TKey first, @@ -651,11 +651,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -716,11 +716,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -779,11 +779,11 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -797,7 +797,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, TKey first, @@ -831,11 +831,11 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -848,7 +848,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, TKey first, @@ -883,12 +883,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -952,12 +952,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1019,12 +1019,12 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1038,7 +1038,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, TKey first, @@ -1074,12 +1074,12 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1092,7 +1092,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, TKey first, @@ -1129,13 +1129,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1202,13 +1202,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1273,13 +1273,13 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1293,7 +1293,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, TKey first, @@ -1331,13 +1331,13 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1350,7 +1350,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, TKey first, @@ -1389,14 +1389,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1466,14 +1466,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1541,14 +1541,14 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1562,7 +1562,7 @@ public static IEnumerable BatchBy( /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, TKey first, @@ -1602,14 +1602,14 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1622,7 +1622,7 @@ public static IEnumerable BatchBy( /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, TKey first, diff --git a/MoreLinq/BatchBy.g.tt b/MoreLinq/BatchBy.g.tt index 168d7d077..65eda3773 100644 --- a/MoreLinq/BatchBy.g.tt +++ b/MoreLinq/BatchBy.g.tt @@ -25,8 +25,8 @@ var ordinals = new[] { "", - "first", "second", "third", "fourth", - "fifth", "sixth", "seventh", "eighth" + "First", "Second", "Third", "Fourth", + "Fifth", "Sixth", "Seventh", "Eighth" }; var overloads = @@ -38,6 +38,7 @@ IsFirst = argPosition == 1, IsLast = argPosition == argCount, Name = ordinals[argPosition], + name = ordinals[argPosition].ToLower(), Ordinal = ordinals[argPosition], // Objects associated with the argument Enumerator = $"e{argPosition}", @@ -74,7 +75,7 @@ namespace MoreLinq /// Type of the projected value. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The function used to project the buckets. @@ -86,7 +87,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #>, <# } #> + /// <# foreach (var arg in o.Arguments) { #>, <# } #> /// , or is null /// There is some duplicate keys relatively to . @@ -94,7 +95,7 @@ namespace MoreLinq public static IEnumerable BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.Name#>, + TKey <#=arg.name#>, <# } #> Func keySelector, Func<<# foreach (var arg in o.Arguments) { #>TSource, <#}#>TResult> resultSelector, @@ -105,14 +106,14 @@ namespace MoreLinq var keys = new [] { <# foreach (var arg in o.Arguments) { #> - <#=arg.Name#><#= arg.IsLast ? "" : "," #> + <#=arg.name#><#= arg.IsLast ? "" : "," #> <# } #> }; return BatchBy(source, keys, keySelector, keyComparer) .Select(d => resultSelector( <# foreach (var arg in o.Arguments) { #> - d[<#=arg.Name#>]<#= arg.IsLast ? "));" : "," #> + d[<#=arg.name#>]<#= arg.IsLast ? "));" : "," #> <# } #> } @@ -132,7 +133,7 @@ namespace MoreLinq /// Type of the projected value. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The function used to project the buckets. @@ -143,7 +144,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #>, <# } #> + /// <# foreach (var arg in o.Arguments) { #>, <# } #> /// or is null /// There is some duplicate keys. @@ -151,7 +152,7 @@ namespace MoreLinq public static IEnumerable BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.Name#>, + TKey <#=arg.name#>, <# } #> Func keySelector, Func<<# foreach (var arg in o.Arguments) { #>TSource, <#}#>TResult> resultSelector) @@ -161,14 +162,14 @@ namespace MoreLinq var keys = new [] { <# foreach (var arg in o.Arguments) { #> - <#=arg.Name#><#= arg.IsLast ? "" : "," #> + <#=arg.name#><#= arg.IsLast ? "" : "," #> <# } #> }; return BatchBy(source, keys, keySelector) .Select(d => resultSelector( <# foreach (var arg in o.Arguments) { #> - d[<#=arg.Name#>]<#= arg.IsLast ? "));" : "," #> + d[<#=arg.name#>]<#= arg.IsLast ? "));" : "," #> <# } #> } @@ -188,7 +189,7 @@ namespace MoreLinq /// Type of elements in sequence. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. @@ -199,7 +200,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #>, <# } #> + /// <# foreach (var arg in o.Arguments) { #>, <# } #> /// or is null /// There is some duplicate keys relatively to @@ -208,14 +209,14 @@ namespace MoreLinq BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.Name#>, + TKey <#=arg.name#>, <# } #> Func keySelector, IEqualityComparer keyComparer) { return BatchBy(source, <# foreach (var arg in o.Arguments) { #> - <#=arg.Name#>, + <#=arg.name#>, <# } #> keySelector, ValueTuple.Create, keyComparer); } @@ -235,7 +236,7 @@ namespace MoreLinq /// Type of elements in sequence. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. @@ -245,7 +246,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> /// is null /// There is some duplicate keys. @@ -254,13 +255,13 @@ namespace MoreLinq BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.Name#>, + TKey <#=arg.name#>, <# } #> Func keySelector) { return BatchBy(source, <# foreach (var arg in o.Arguments) { #> - <#=arg.Name#>, + <#=arg.name#>, <# } #> keySelector, ValueTuple.Create); } diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 440739fdc..8aa037767 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -754,8 +754,8 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -768,7 +768,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second)> + public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, TKey first, @@ -825,9 +825,9 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -840,7 +840,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third)> + public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, TKey first, @@ -864,8 +864,8 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -879,7 +879,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second)> + public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, TKey first, @@ -902,10 +902,10 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -918,7 +918,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, TKey first, @@ -943,9 +943,9 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -959,7 +959,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third)> + public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, TKey first, @@ -983,11 +983,11 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1000,7 +1000,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, TKey first, @@ -1026,10 +1026,10 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1043,7 +1043,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, TKey first, @@ -1068,12 +1068,12 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1086,7 +1086,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, TKey first, @@ -1113,11 +1113,11 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1131,7 +1131,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, TKey first, @@ -1157,13 +1157,13 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1176,7 +1176,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, TKey first, @@ -1204,12 +1204,12 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1223,7 +1223,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, TKey first, @@ -1250,14 +1250,14 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1270,7 +1270,7 @@ public static IEnumerable> BatchBy(thi /// is null /// There is some duplicate keys. - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, TKey first, @@ -1299,13 +1299,13 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1319,7 +1319,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, TKey first, @@ -1348,14 +1348,14 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1369,7 +1369,7 @@ public static IEnumerable> BatchBy(thi /// or is null /// There is some duplicate keys relatively to - public static IEnumerable<(TSource first, TSource second, TSource third, TSource fourth, TSource fifth, TSource sixth, TSource seventh, TSource eighth)> + public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, TKey first, @@ -1399,8 +1399,8 @@ public static IEnumerable> BatchBy(thi /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1437,9 +1437,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1477,8 +1477,8 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1517,10 +1517,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1560,9 +1560,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1602,11 +1602,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1647,10 +1647,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1691,12 +1691,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1738,11 +1738,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1784,13 +1784,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1833,12 +1833,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1881,14 +1881,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1932,13 +1932,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1983,14 +1983,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// first key. - /// second key. - /// third key. - /// fourth key. - /// fifth key. - /// sixth key. - /// seventh key. - /// eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. From 273db6747b877f3f1e7041dd37ef9d9f5fe2ec28 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 7 Nov 2019 12:48:35 +0100 Subject: [PATCH 3/7] Fix unexpected trailing whitespace --- MoreLinq/BatchBy.cs | 12 ++++++------ MoreLinq/Extensions.g.cs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MoreLinq/BatchBy.cs b/MoreLinq/BatchBy.cs index 32e84b586..0e2cb49cd 100644 --- a/MoreLinq/BatchBy.cs +++ b/MoreLinq/BatchBy.cs @@ -29,9 +29,9 @@ static partial class MoreEnumerable /// Each buckets contains all keys and for each of this /// keys a matching value from the sequence. /// The matching is done by the . - /// + /// /// Values from sequence that doesn't have a matching key are discarded. - /// + /// /// For each key/value pair in a buckets, key and keySelector(value) are equals /// relatively to the . /// @@ -44,7 +44,7 @@ static partial class MoreEnumerable /// The build up sequence of buckets. /// /// This operator uses deferred execution and streams its results. - /// + /// /// The sequence is fully consumed on first iteration. /// If is empty, is not enumerated. /// Values from that correspond to a null key are discarded. @@ -99,9 +99,9 @@ public static IEnumerable> BatchBy(thi /// Each buckets contains all keys and for each of this /// keys a matching value from the sequence. /// The matching is done by the . - /// + /// /// Values from sequence that doesn't have a matching key are discarded. - /// + /// /// For each key/value pair in a buckets, key and keySelector(value) are equals /// relatively to the default equality comparer. /// @@ -113,7 +113,7 @@ public static IEnumerable> BatchBy(thi /// The build up sequence of buckets. /// /// This operator uses deferred execution and streams its results. - /// + /// /// The sequence is fully consumed on first iteration. /// If is empty, is not enumerated. /// Values from that correspond to a null key are discarded. diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 8aa037767..9cbbc49d0 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -712,9 +712,9 @@ public static partial class BatchByExtension /// Each buckets contains all keys and for each of this /// keys a matching value from the sequence. /// The matching is done by the . - /// + /// /// Values from sequence that doesn't have a matching key are discarded. - /// + /// /// For each key/value pair in a buckets, key and keySelector(value) are equals /// relatively to the default equality comparer. /// @@ -726,7 +726,7 @@ public static partial class BatchByExtension /// The build up sequence of buckets. /// /// This operator uses deferred execution and streams its results. - /// + /// /// The sequence is fully consumed on first iteration. /// If is empty, is not enumerated. /// Values from that correspond to a null key are discarded. @@ -780,9 +780,9 @@ public static IEnumerable> BatchBy(thi /// Each buckets contains all keys and for each of this /// keys a matching value from the sequence. /// The matching is done by the . - /// + /// /// Values from sequence that doesn't have a matching key are discarded. - /// + /// /// For each key/value pair in a buckets, key and keySelector(value) are equals /// relatively to the . /// @@ -795,7 +795,7 @@ public static IEnumerable> BatchBy(thi /// The build up sequence of buckets. /// /// This operator uses deferred execution and streams its results. - /// + /// /// The sequence is fully consumed on first iteration. /// If is empty, is not enumerated. /// Values from that correspond to a null key are discarded. From da2caba259c86a6819c08fe80e23223732b4f43b Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 7 Nov 2019 12:56:23 +0100 Subject: [PATCH 4/7] Fix unexpected trailing whitespace --- MoreLinq/BatchBy.g.cs | 42 ++++++++++++++++++++-------------------- MoreLinq/BatchBy.g.tt | 6 +++--- MoreLinq/Extensions.g.cs | 42 ++++++++++++++++++++-------------------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/MoreLinq/BatchBy.g.cs b/MoreLinq/BatchBy.g.cs index 3fde328a6..766fd57aa 100644 --- a/MoreLinq/BatchBy.g.cs +++ b/MoreLinq/BatchBy.g.cs @@ -51,7 +51,7 @@ static partial class MoreEnumerable /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// , or is null /// There is some duplicate keys relatively to . @@ -103,7 +103,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys. @@ -154,7 +154,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys relatively to @@ -242,7 +242,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// , or is null /// There is some duplicate keys relatively to . @@ -298,7 +298,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys. @@ -353,7 +353,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys relatively to @@ -447,7 +447,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -507,7 +507,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys. @@ -566,7 +566,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys relatively to @@ -666,7 +666,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -730,7 +730,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys. @@ -793,7 +793,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys relatively to @@ -899,7 +899,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -967,7 +967,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys. @@ -1034,7 +1034,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys relatively to @@ -1146,7 +1146,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -1218,7 +1218,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys. @@ -1289,7 +1289,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys relatively to @@ -1407,7 +1407,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -1483,7 +1483,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys. @@ -1558,7 +1558,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys relatively to diff --git a/MoreLinq/BatchBy.g.tt b/MoreLinq/BatchBy.g.tt index 65eda3773..625927183 100644 --- a/MoreLinq/BatchBy.g.tt +++ b/MoreLinq/BatchBy.g.tt @@ -87,7 +87,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #>, <# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> /// , or is null /// There is some duplicate keys relatively to . @@ -144,7 +144,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #>, <# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> /// or is null /// There is some duplicate keys. @@ -200,7 +200,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #>, <# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> /// or is null /// There is some duplicate keys relatively to diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 9cbbc49d0..490ed22cc 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -875,7 +875,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys relatively to @@ -955,7 +955,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys relatively to @@ -1039,7 +1039,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys relatively to @@ -1127,7 +1127,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys relatively to @@ -1219,7 +1219,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys relatively to @@ -1315,7 +1315,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys relatively to @@ -1365,7 +1365,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys relatively to @@ -1410,7 +1410,7 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys. @@ -1449,7 +1449,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys. @@ -1489,7 +1489,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// , or is null /// There is some duplicate keys relatively to . @@ -1530,7 +1530,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys. @@ -1573,7 +1573,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// , or is null /// There is some duplicate keys relatively to . @@ -1616,7 +1616,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys. @@ -1661,7 +1661,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -1706,7 +1706,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys. @@ -1753,7 +1753,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -1800,7 +1800,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys. @@ -1849,7 +1849,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -1898,7 +1898,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys. @@ -1949,7 +1949,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// , or is null /// There is some duplicate keys relatively to . @@ -2001,7 +2001,7 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// , or is null /// There is some duplicate keys relatively to . From 4f0da51474cbb7047147f91074f753087a461433 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 7 Nov 2019 13:12:37 +0100 Subject: [PATCH 5/7] Allow null equality comparer --- MoreLinq/BatchBy.cs | 7 +++-- MoreLinq/BatchBy.g.cs | 56 ++++++++++++++++++++++-------------- MoreLinq/BatchBy.g.tt | 8 ++++-- MoreLinq/Extensions.g.cs | 61 +++++++++++++++++++++++++--------------- 4 files changed, 82 insertions(+), 50 deletions(-) diff --git a/MoreLinq/BatchBy.cs b/MoreLinq/BatchBy.cs index 0e2cb49cd..621f9cf3d 100644 --- a/MoreLinq/BatchBy.cs +++ b/MoreLinq/BatchBy.cs @@ -48,9 +48,10 @@ static partial class MoreEnumerable /// The sequence is fully consumed on first iteration. /// If is empty, is not enumerated. /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// - /// , , - /// or is null + /// , or + /// is null /// contains null /// contains duplicate keys relatively to /// . @@ -62,7 +63,7 @@ public static IEnumerable> BatchBy(thi if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); if (acceptedKeys == null) throw new ArgumentNullException(nameof(acceptedKeys)); - if (keyComparer == null) throw new ArgumentNullException(nameof(keyComparer)); + keyComparer ??= EqualityComparer.Default; return _(); IEnumerable> _() { diff --git a/MoreLinq/BatchBy.g.cs b/MoreLinq/BatchBy.g.cs index 766fd57aa..b56293a78 100644 --- a/MoreLinq/BatchBy.g.cs +++ b/MoreLinq/BatchBy.g.cs @@ -49,10 +49,11 @@ static partial class MoreEnumerable /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -152,10 +153,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , - /// or is null + /// , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second)> @@ -240,10 +242,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -351,10 +354,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , - /// or is null + /// , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third)> @@ -445,10 +449,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -564,10 +569,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , - /// or is null + /// , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> @@ -664,10 +670,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -791,10 +798,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , - /// or is null + /// , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> @@ -897,10 +905,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1032,10 +1041,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , - /// or is null + /// , , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> @@ -1144,10 +1154,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1287,10 +1298,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , - /// or is null + /// , , , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> @@ -1405,10 +1417,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1556,10 +1569,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , , - /// or is null + /// , , , , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> diff --git a/MoreLinq/BatchBy.g.tt b/MoreLinq/BatchBy.g.tt index 625927183..35d579a9f 100644 --- a/MoreLinq/BatchBy.g.tt +++ b/MoreLinq/BatchBy.g.tt @@ -85,11 +85,12 @@ namespace MoreLinq /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -198,11 +199,12 @@ namespace MoreLinq /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> - /// or is null + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.Name#><#=arg.IsLast?"":", "#><#}#>)> diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index 490ed22cc..b22d140f6 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -799,9 +799,10 @@ public static IEnumerable> BatchBy(thi /// The sequence is fully consumed on first iteration. /// If is empty, is not enumerated. /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// - /// , , - /// or is null + /// , or + /// is null /// contains null /// contains duplicate keys relatively to /// . @@ -873,10 +874,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , - /// or is null + /// , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second)> @@ -953,10 +955,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , - /// or is null + /// , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third)> @@ -1037,10 +1040,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , - /// or is null + /// , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> @@ -1125,10 +1129,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , - /// or is null + /// , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> @@ -1217,10 +1222,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , - /// or is null + /// , , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> @@ -1313,10 +1319,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , - /// or is null + /// , , , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> @@ -1363,10 +1370,11 @@ public static IEnumerable> BatchBy(thi /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , , - /// or is null + /// , , , , , , , or + /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> @@ -1487,10 +1495,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1571,10 +1580,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1659,10 +1669,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1751,10 +1762,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1847,10 +1859,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1947,10 +1960,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( @@ -1999,10 +2013,11 @@ public static IEnumerable BatchBy( /// This operator uses deferred execution and streams its results. /// /// Values from that correspond to a null key are discarded. + /// If is null, EqualityComparer.Default is used. /// /// , /// , , , , , , , , - /// , or is null + /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( From c0044fda1feef02eb80175ae485a7ca878d9fcbe Mon Sep 17 00:00:00 2001 From: Orace Date: Fri, 8 Nov 2019 10:48:53 +0100 Subject: [PATCH 6/7] Add BatchByDoNotReEnumerateSourceOnMultipleEnumeration test --- MoreLinq.Test/BatchByTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MoreLinq.Test/BatchByTests.cs b/MoreLinq.Test/BatchByTests.cs index 727fdab7f..9b4196a37 100644 --- a/MoreLinq.Test/BatchByTests.cs +++ b/MoreLinq.Test/BatchByTests.cs @@ -85,6 +85,24 @@ void Code() Assert.DoesNotThrow(Code); } + [Test] + public void BatchByDoNotReEnumerateSourceOnMultipleEnumeration() + { + var source = Enumerable.Range(0, 5); + static string KeySelector(int i) => $"{i}"; + var acceptedKeys = TestingSequence.Of("0", "1", "2", "3"); + var equalityComparer = EqualityComparer.Default; + + void Code() + { + var enumerable = source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + enumerable.Consume(); + enumerable.Consume(); + } + + Assert.DoesNotThrow(Code); + } + [Test] public void BatchByDoNotThrowOnDuplicateAcceptedKeyAtCreation() { From f20d952f1f8817e8f31c5969158bd0749fd17b6a Mon Sep 17 00:00:00 2001 From: Orace Date: Fri, 8 Nov 2019 12:44:04 +0100 Subject: [PATCH 7/7] Improve BatchBy implementation --- MoreLinq.Test/BatchByTests.cs | 6 +- MoreLinq/BatchBy.cs | 147 ++++- MoreLinq/BatchBy.g.cs | 1134 +++++++++++++++------------------ MoreLinq/BatchBy.g.tt | 103 ++- MoreLinq/Extensions.g.cs | 674 ++++++++++---------- 5 files changed, 1042 insertions(+), 1022 deletions(-) diff --git a/MoreLinq.Test/BatchByTests.cs b/MoreLinq.Test/BatchByTests.cs index 9b4196a37..26811acdf 100644 --- a/MoreLinq.Test/BatchByTests.cs +++ b/MoreLinq.Test/BatchByTests.cs @@ -171,13 +171,13 @@ void Code() public void BatchByIsLazy() { var source = new BreakingSequence(); - static string KeySelector(int i) => $"{i}"; - var acceptedKeys = TestingSequence.Of("0", "1", "2", "3"); + var keySelector = BreakingFunc.Of(); + var acceptedKeys = new BreakingSequence(); var equalityComparer = EqualityComparer.Default; void Code() { - source.BatchBy(acceptedKeys, KeySelector, equalityComparer); + source.BatchBy(acceptedKeys, keySelector, equalityComparer); } Assert.DoesNotThrow(Code); diff --git a/MoreLinq/BatchBy.cs b/MoreLinq/BatchBy.cs index 621f9cf3d..0da066248 100644 --- a/MoreLinq/BatchBy.cs +++ b/MoreLinq/BatchBy.cs @@ -55,6 +55,7 @@ static partial class MoreEnumerable /// contains null /// contains duplicate keys relatively to /// . + public static IEnumerable> BatchBy(this IEnumerable source, IEnumerable acceptedKeys, Func keySelector, @@ -65,32 +66,34 @@ public static IEnumerable> BatchBy(thi if (acceptedKeys == null) throw new ArgumentNullException(nameof(acceptedKeys)); keyComparer ??= EqualityComparer.Default; - return _(); IEnumerable> _() + (IList Keys, IDictionary IndexByKey) BuildContext() { - var queues = acceptedKeys.ToDictionary(k => k, k => new Queue(), keyComparer); + var keys = acceptedKeys.ToList(); + var indexByKey = new Dictionary(keyComparer); + var index = 0; + foreach (var key in keys) + { + indexByKey.Add(key, index); + index++; + } - // early break - if (queues.Count == 0) - yield break; + return (keys, indexByKey); + } + var lazyContext = new Lazy<(IList Keys, IDictionary IndexByKey)>(BuildContext); - var emptyQueueCount = queues.Count; - foreach (var value in source) + return _(); IEnumerable> _() + { + // Lazy creation of the index table and enumeration of acceptedKeys + var (keys, indexByKey) = lazyContext.Value; + foreach (var batch in BatchByImplementation(source, indexByKey, keySelector)) { - var key = keySelector(value); - - if (key != null && queues.TryGetValue(key, out var queue)) + var nextResult = new Dictionary(keys.Count, keyComparer); + for (var i = 0; i < keys.Count; i++) { - queue.Enqueue(value); - if (queue.Count == 1) - emptyQueueCount--; + nextResult.Add(keys[i], batch[i]); } - // We need more elements - if (emptyQueueCount > 0) - continue; - - yield return queues.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Dequeue()); - emptyQueueCount = queues.Values.Count(q => q.Count == 0); + yield return nextResult; } } } @@ -123,11 +126,117 @@ public static IEnumerable> BatchBy(thi /// is null /// contains null /// contains duplicate keys. + public static IEnumerable> BatchBy(this IEnumerable source, IEnumerable acceptedKeys, Func keySelector) { return BatchBy(source, acceptedKeys, keySelector, EqualityComparer.Default); } + + private static IEnumerable> BatchByImplementation(this IEnumerable source, + IEnumerable acceptedKeys, + Func keySelector, + IEqualityComparer keyComparer) + { + if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (acceptedKeys == null) throw new ArgumentNullException(nameof(acceptedKeys)); + keyComparer ??= EqualityComparer.Default; + + IDictionary BuildIndexByKey() + { + var indexByKey = new Dictionary(keyComparer); + var index = 0; + foreach (var key in acceptedKeys) + { + indexByKey.Add(key, index); + index++; + } + + return indexByKey; + } + var lazyIndexByKey = new Lazy>(BuildIndexByKey); + + return _(); IEnumerable> _() + { + // Lazy creation of the index table + var indexByKey = lazyIndexByKey.Value; + foreach (var batch in BatchByImplementation(source, indexByKey, keySelector)) + { + yield return batch; + } + } + } + + private static IEnumerable> BatchByImplementation(IEnumerable source, + IDictionary indexByKey, Func keySelector) + { + var batchSize = indexByKey.Count; + + // acceptedKeys was empty. + if (batchSize == 0) + yield break; + + var queues = new Queue[batchSize]; + for (var i = 0; i < batchSize; i++) + { + queues[i] = new Queue(); + } + + var batch = new TSource[batchSize]; + var takenSlots = new bool[batchSize]; + var emptySlotCount = batchSize; + foreach (var value in source) + { + var key = keySelector(value); + + // reject null key + if (key == null) + continue; + + // reject unknown keys + if (!indexByKey.TryGetValue(key, out var index)) + continue; + + // the slot is already taken, enqueue the value + if (takenSlots[index]) + { + var targetQueue = queues[index]; + targetQueue.Enqueue(value); + continue; + } + + // fill the slot + batch[index] = value; + takenSlots[index] = true; + emptySlotCount--; + + // there are empty slots left, can't yield yet + if (emptySlotCount > 0) + continue; + + // finally can yield a batch + yield return batch; + + // prepare next batch + batch = new TSource[batchSize]; + for (var i = 0; i < batchSize; i++) + { + var queue = queues[i]; + if (queue.Count == 0) + { + takenSlots[i] = false; + emptySlotCount++; + } + else + { + batch[i] = queue.Dequeue(); + takenSlots[i] = true; + } + } + + } + } } } diff --git a/MoreLinq/BatchBy.g.cs b/MoreLinq/BatchBy.g.cs index b56293a78..b337f6312 100644 --- a/MoreLinq/BatchBy.g.cs +++ b/MoreLinq/BatchBy.g.cs @@ -39,8 +39,8 @@ static partial class MoreEnumerable /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -52,14 +52,14 @@ static partial class MoreEnumerable /// If is null, EqualityComparer.Default is used. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -68,14 +68,12 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second + firstKey, + secondKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1])); } /// @@ -93,8 +91,8 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -104,29 +102,21 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second])); + return BatchBy(source, + firstKey, + secondKey, + keySelector, resultSelector, null); } /// @@ -144,8 +134,8 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -156,22 +146,26 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , or + /// , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1])); } /// @@ -188,8 +182,8 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -198,21 +192,21 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , or + /// , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector) { return BatchBy(source, - first, - second, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + keySelector, null); } /// @@ -231,9 +225,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -245,15 +239,15 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -262,16 +256,13 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second, - third + firstKey, + secondKey, + thirdKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second], - d[third])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1], d[2])); } /// @@ -289,9 +280,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -301,32 +292,23 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second, - third - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second], - d[third])); + return BatchBy(source, + firstKey, + secondKey, + thirdKey, + keySelector, resultSelector, null); } /// @@ -344,9 +326,9 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -357,24 +339,28 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , or + /// , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - third, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey, + thirdKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1], d[2])); } /// @@ -391,9 +377,9 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -402,23 +388,23 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , or + /// , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector) { return BatchBy(source, - first, - second, - third, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + thirdKey, + keySelector, null); } /// @@ -437,10 +423,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -452,16 +438,16 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -470,18 +456,14 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second, - third, - fourth + firstKey, + secondKey, + thirdKey, + fourthKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1], d[2], d[3])); } /// @@ -499,10 +481,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -512,35 +494,25 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second, - third, - fourth - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth])); + return BatchBy(source, + firstKey, + secondKey, + thirdKey, + fourthKey, + keySelector, resultSelector, null); } /// @@ -558,10 +530,10 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -572,26 +544,30 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , or + /// , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - third, - fourth, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey, + thirdKey, + fourthKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1], d[2], d[3])); } /// @@ -608,10 +584,10 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -620,25 +596,25 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , or + /// , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector) { return BatchBy(source, - first, - second, - third, - fourth, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + thirdKey, + fourthKey, + keySelector, null); } /// @@ -657,11 +633,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -673,17 +649,17 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -692,20 +668,15 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second, - third, - fourth, - fifth + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1], d[2], d[3], d[4])); } /// @@ -723,11 +694,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -737,38 +708,27 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second, - third, - fourth, - fifth - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth])); + return BatchBy(source, + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + keySelector, resultSelector, null); } /// @@ -786,11 +746,11 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -801,28 +761,32 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , or + /// , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - third, - fourth, - fifth, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1], d[2], d[3], d[4])); } /// @@ -839,11 +803,11 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -852,27 +816,27 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , or + /// , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector) { return BatchBy(source, - first, - second, - third, - fourth, - fifth, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + keySelector, null); } /// @@ -891,12 +855,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -908,18 +872,18 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -928,22 +892,16 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second, - third, - fourth, - fifth, - sixth + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth], - d[sixth])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1], d[2], d[3], d[4], d[5])); } /// @@ -961,12 +919,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -976,41 +934,29 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second, - third, - fourth, - fifth, - sixth - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth], - d[sixth])); + return BatchBy(source, + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + keySelector, resultSelector, null); } /// @@ -1028,12 +974,12 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1044,30 +990,34 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , or + /// , , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - third, - fourth, - fifth, - sixth, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1], d[2], d[3], d[4], d[5])); } /// @@ -1084,12 +1034,12 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1098,29 +1048,29 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , or + /// , , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector) { return BatchBy(source, - first, - second, - third, - fourth, - fifth, - sixth, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + keySelector, null); } /// @@ -1139,13 +1089,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1157,19 +1107,19 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -1178,24 +1128,17 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second, - third, - fourth, - fifth, - sixth, - seventh + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth], - d[sixth], - d[seventh])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1], d[2], d[3], d[4], d[5], d[6])); } /// @@ -1213,13 +1156,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1229,44 +1172,31 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second, - third, - fourth, - fifth, - sixth, - seventh - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth], - d[sixth], - d[seventh])); + return BatchBy(source, + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey, + keySelector, resultSelector, null); } /// @@ -1284,13 +1214,13 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1301,32 +1231,36 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , or + /// , , , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - third, - fourth, - fifth, - sixth, - seventh, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1], d[2], d[3], d[4], d[5], d[6])); } /// @@ -1343,13 +1277,13 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1358,31 +1292,31 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , or + /// , , , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector) { return BatchBy(source, - first, - second, - third, - fourth, - fifth, - sixth, - seventh, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey, + keySelector, null); } /// @@ -1401,14 +1335,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1420,20 +1354,20 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) @@ -1442,26 +1376,18 @@ public static IEnumerable BatchBy( var keys = new [] { - first, - second, - third, - fourth, - fifth, - sixth, - seventh, - eighth + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey, + eighthKey }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth], - d[sixth], - d[seventh], - d[eighth])); + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7])); } /// @@ -1479,14 +1405,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1496,47 +1422,33 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector, Func resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { - first, - second, - third, - fourth, - fifth, - sixth, - seventh, - eighth - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( - d[first], - d[second], - d[third], - d[fourth], - d[fifth], - d[sixth], - d[seventh], - d[eighth])); + return BatchBy(source, + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey, + eighthKey, + keySelector, resultSelector, null); } /// @@ -1554,14 +1466,14 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1572,34 +1484,38 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , or + /// , , , , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, - first, - second, - third, - fourth, - fifth, - sixth, - seventh, - eighth, - keySelector, ValueTuple.Create, keyComparer); + var keys = new [] + { + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey, + eighthKey + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7])); } /// @@ -1616,14 +1532,14 @@ public static IEnumerable BatchBy( /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1632,33 +1548,33 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , or + /// , , , , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector) { return BatchBy(source, - first, - second, - third, - fourth, - fifth, - sixth, - seventh, - eighth, - keySelector, ValueTuple.Create); + firstKey, + secondKey, + thirdKey, + fourthKey, + fifthKey, + sixthKey, + seventhKey, + eighthKey, + keySelector, null); } } diff --git a/MoreLinq/BatchBy.g.tt b/MoreLinq/BatchBy.g.tt index 35d579a9f..d8fa00afa 100644 --- a/MoreLinq/BatchBy.g.tt +++ b/MoreLinq/BatchBy.g.tt @@ -24,28 +24,27 @@ <# var ordinals = new[] { - "", + string.Empty, "First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth" }; var overloads = - Enumerable.Range(2, 7) - .Select(argCount => - Enumerable.Range(1, argCount).Select(argPosition => - new - { - IsFirst = argPosition == 1, - IsLast = argPosition == argCount, - Name = ordinals[argPosition], - name = ordinals[argPosition].ToLower(), - Ordinal = ordinals[argPosition], - // Objects associated with the argument - Enumerator = $"e{argPosition}", - Value = $"v{argPosition}" - })) - .Select(args => args.ToList()) - .Select(args => new { Arguments = args }); + from argCount in Enumerable.Range(2, 7) + select new + { + Arguments = + from argPosition in Enumerable.Range(1, argCount) + select new + { + Index = argPosition - 1, + IsFirst = argPosition == 1, + IsLast = argPosition == argCount, + KeyName = ordinals[argPosition].ToLower() + "Key", + Ordinal = ordinals[argPosition], + OutName = ordinals[argPosition] + } + }; #> namespace MoreLinq { @@ -75,7 +74,7 @@ namespace MoreLinq /// Type of the projected value. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The function used to project the buckets. @@ -88,7 +87,7 @@ namespace MoreLinq /// If is null, EqualityComparer.Default is used. /// /// , - /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> /// or is null /// There is some duplicate keys relatively to . @@ -96,7 +95,7 @@ namespace MoreLinq public static IEnumerable BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.name#>, + TKey <#=arg.KeyName#>, <# } #> Func keySelector, Func<<# foreach (var arg in o.Arguments) { #>TSource, <#}#>TResult> resultSelector, @@ -107,15 +106,13 @@ namespace MoreLinq var keys = new [] { <# foreach (var arg in o.Arguments) { #> - <#=arg.name#><#= arg.IsLast ? "" : "," #> + <#=arg.KeyName#><#= arg.IsLast ? "" : "," #> <# } #> }; - return BatchBy(source, keys, keySelector, keyComparer) - .Select(d => resultSelector( -<# foreach (var arg in o.Arguments) { #> - d[<#=arg.name#>]<#= arg.IsLast ? "));" : "," #> -<# } #> + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => resultSelector(<# foreach (var arg in o.Arguments) { #>d[<#= arg.Index #>]<#= arg.IsLast ? "" : ", " #><# } #> +)); } /// @@ -134,7 +131,7 @@ namespace MoreLinq /// Type of the projected value. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The function used to project the buckets. @@ -145,7 +142,7 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?",":", "#><# } #> /// or is null /// There is some duplicate keys. @@ -153,25 +150,16 @@ namespace MoreLinq public static IEnumerable BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.name#>, + TKey <#=arg.KeyName#>, <# } #> Func keySelector, Func<<# foreach (var arg in o.Arguments) { #>TSource, <#}#>TResult> resultSelector) { - if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - - var keys = new [] - { -<# foreach (var arg in o.Arguments) { #> - <#=arg.name#><#= arg.IsLast ? "" : "," #> -<# } #> - }; - - return BatchBy(source, keys, keySelector) - .Select(d => resultSelector( + return BatchBy(source, <# foreach (var arg in o.Arguments) { #> - d[<#=arg.name#>]<#= arg.IsLast ? "));" : "," #> + <#=arg.KeyName#>, <# } #> + keySelector, resultSelector, null); } /// @@ -190,7 +178,7 @@ namespace MoreLinq /// Type of elements in sequence. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. @@ -202,25 +190,30 @@ namespace MoreLinq /// If is null, EqualityComparer.Default is used. /// /// , - /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> /// is null /// There is some duplicate keys relatively to - public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.Name#><#=arg.IsLast?"":", "#><#}#>)> + public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.OutName#><#=arg.IsLast?"":", "#><#}#>)> BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.name#>, + TKey <#=arg.KeyName#>, <# } #> Func keySelector, IEqualityComparer keyComparer) { - return BatchBy(source, + var keys = new [] + { <# foreach (var arg in o.Arguments) { #> - <#=arg.name#>, + <#=arg.KeyName#><#= arg.IsLast ? "" : "," #> <# } #> - keySelector, ValueTuple.Create, keyComparer); + }; + + return BatchByImplementation(source, keys, keySelector, keyComparer) + .Select(d => ValueTuple.Create(<# foreach (var arg in o.Arguments) { #>d[<#= arg.Index #>]<#= arg.IsLast ? "" : ", " #><# } #> +)); } /// @@ -238,7 +231,7 @@ namespace MoreLinq /// Type of elements in sequence. /// The source sequence. <# foreach (var arg in o.Arguments) { #> - /// <#=arg.Ordinal#> key. + /// <#=arg.Ordinal#> key. <# } #> /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. @@ -248,24 +241,24 @@ namespace MoreLinq /// Values from that correspond to a null key are discarded. /// /// , - /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> + /// <# foreach (var arg in o.Arguments) { #><#=arg.IsLast?" or":", "#><# } #> /// is null /// There is some duplicate keys. - public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.Name#><#=arg.IsLast?"":", "#><#}#>)> + public static IEnumerable<(<# foreach (var arg in o.Arguments) { #>TSource <#=arg.OutName#><#=arg.IsLast?"":", "#><#}#>)> BatchBy( this IEnumerable source, <# foreach (var arg in o.Arguments) { #> - TKey <#=arg.name#>, + TKey <#=arg.KeyName#>, <# } #> Func keySelector) { return BatchBy(source, <# foreach (var arg in o.Arguments) { #> - <#=arg.name#>, -<# } #> - keySelector, ValueTuple.Create); + <#=arg.KeyName#>, +<# } #> + keySelector, null); } <# } #> diff --git a/MoreLinq/Extensions.g.cs b/MoreLinq/Extensions.g.cs index b22d140f6..2af0d4bf8 100644 --- a/MoreLinq/Extensions.g.cs +++ b/MoreLinq/Extensions.g.cs @@ -735,6 +735,7 @@ public static partial class BatchByExtension /// is null /// contains null /// contains duplicate keys. + public static IEnumerable> BatchBy(this IEnumerable source, IEnumerable acceptedKeys, Func keySelector) @@ -754,8 +755,8 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -764,17 +765,17 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , or + /// , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. /// Each buckets contains all keys and for each of this @@ -806,6 +807,7 @@ public static IEnumerable> BatchBy(thi /// contains null /// contains duplicate keys relatively to /// . + public static IEnumerable> BatchBy(this IEnumerable source, IEnumerable acceptedKeys, Func keySelector, @@ -826,9 +828,9 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -837,18 +839,18 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , or + /// , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, third, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -865,8 +867,8 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -877,18 +879,18 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , or + /// , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second)> BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -904,10 +906,10 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -916,19 +918,19 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , or + /// , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -945,9 +947,9 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -958,19 +960,19 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , , or + /// , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, third, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -986,11 +988,11 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -999,20 +1001,20 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , or + /// , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1029,10 +1031,10 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1043,20 +1045,20 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , or + /// , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1072,12 +1074,12 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1086,21 +1088,21 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , or + /// , , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1117,11 +1119,11 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1132,21 +1134,21 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , or + /// , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1162,13 +1164,13 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1177,22 +1179,22 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , or + /// , , , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1209,12 +1211,12 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1225,22 +1227,22 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , or + /// , , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1256,14 +1258,14 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The build up sequence of projected buckets. /// @@ -1272,23 +1274,23 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , or + /// , , , , , , , or /// is null /// There is some duplicate keys. public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, eighthKey, keySelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1305,13 +1307,13 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1322,23 +1324,23 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , or + /// , , , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1355,14 +1357,14 @@ public static IEnumerable> BatchBy(thi /// The type of the keys of the buckets. /// Type of elements in sequence. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The comparer used to evaluate keys equality. /// The build up sequence of projected buckets. @@ -1373,24 +1375,24 @@ public static IEnumerable> BatchBy(thi /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , or + /// , , , , , , , or /// is null /// There is some duplicate keys relatively to public static IEnumerable<(TSource First, TSource Second, TSource Third, TSource Fourth, TSource Fifth, TSource Sixth, TSource Seventh, TSource Eighth)> BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector, IEqualityComparer keyComparer) - => MoreEnumerable. BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector, keyComparer); + => MoreEnumerable. BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, eighthKey, keySelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1407,8 +1409,8 @@ public static IEnumerable> BatchBy(thi /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1418,17 +1420,17 @@ public static IEnumerable> BatchBy(thi /// Values from that correspond to a null key are discarded. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1445,9 +1447,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1457,18 +1459,18 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, third, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. /// Then the buckets values are projected with . @@ -1485,8 +1487,8 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. + /// First key. + /// Second key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1498,18 +1500,18 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , + /// , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, + TKey firstKey, + TKey secondKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, keySelector, resultSelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1526,10 +1528,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1539,19 +1541,19 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1569,9 +1571,9 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. + /// First key. + /// Second key. + /// Third key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1583,19 +1585,19 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , + /// , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, + TKey firstKey, + TKey secondKey, + TKey thirdKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, third, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, keySelector, resultSelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1612,11 +1614,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1626,20 +1628,20 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1657,10 +1659,10 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1672,20 +1674,20 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , + /// , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, keySelector, resultSelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1702,12 +1704,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1717,21 +1719,21 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1749,11 +1751,11 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1765,21 +1767,21 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , + /// , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, keySelector, resultSelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1796,13 +1798,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1812,22 +1814,22 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1845,12 +1847,12 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1862,22 +1864,22 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , + /// , , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, keySelector, resultSelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1894,14 +1896,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The build up sequence of projected buckets. @@ -1911,23 +1913,23 @@ public static IEnumerable BatchBy( /// Values from that correspond to a null key are discarded. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys. public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector, Func resultSelector) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector, resultSelector); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, eighthKey, keySelector, resultSelector); /// /// Batch the sequence into buckets that are IDictionary. @@ -1945,13 +1947,13 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -1963,23 +1965,23 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , + /// , , , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, keySelector, resultSelector, keyComparer); /// /// Batch the sequence into buckets that are IDictionary. @@ -1997,14 +1999,14 @@ public static IEnumerable BatchBy( /// Type of elements in sequence. /// Type of the projected value. /// The source sequence. - /// First key. - /// Second key. - /// Third key. - /// Fourth key. - /// Fifth key. - /// Sixth key. - /// Seventh key. - /// Eighth key. + /// First key. + /// Second key. + /// Third key. + /// Fourth key. + /// Fifth key. + /// Sixth key. + /// Seventh key. + /// Eighth key. /// Build the key for elements from the sequence. /// The function used to project the buckets. /// The comparer used to evaluate keys equality. @@ -2016,24 +2018,24 @@ public static IEnumerable BatchBy( /// If is null, EqualityComparer.Default is used. /// /// , - /// , , , , , , , , + /// , , , , , , , , /// or is null /// There is some duplicate keys relatively to . public static IEnumerable BatchBy( this IEnumerable source, - TKey first, - TKey second, - TKey third, - TKey fourth, - TKey fifth, - TKey sixth, - TKey seventh, - TKey eighth, + TKey firstKey, + TKey secondKey, + TKey thirdKey, + TKey fourthKey, + TKey fifthKey, + TKey sixthKey, + TKey seventhKey, + TKey eighthKey, Func keySelector, Func resultSelector, IEqualityComparer keyComparer) - => MoreEnumerable.BatchBy(source, first, second, third, fourth, fifth, sixth, seventh, eighth, keySelector, resultSelector, keyComparer); + => MoreEnumerable.BatchBy(source, firstKey, secondKey, thirdKey, fourthKey, fifthKey, sixthKey, seventhKey, eighthKey, keySelector, resultSelector, keyComparer); }