From 0123ec60d6f49a62cbe0a6f2d5a867bf2258969b Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 20 Apr 2022 16:26:15 +0100 Subject: [PATCH] Remove IEnumerable.Split(int) This functionality has been introduced in .NET 6 with the Chunk method: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.chunk?view=net-6.0 --- .../EnumerableExtensions.cs | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/X10D/src/EnumerableExtensions/EnumerableExtensions.cs b/X10D/src/EnumerableExtensions/EnumerableExtensions.cs index 65d5072..cd7098b 100644 --- a/X10D/src/EnumerableExtensions/EnumerableExtensions.cs +++ b/X10D/src/EnumerableExtensions/EnumerableExtensions.cs @@ -17,40 +17,4 @@ public static partial class EnumerableExtensions list.Shuffle(random); return list.AsReadOnly(); } - - /// - /// Splits into chunks of size . - /// - /// Any type. - /// The collection to split. - /// The maximum length of the nested collection. - /// - /// An containing an of - /// whose lengths are no greater than . - /// - public static IEnumerable> Split(this IEnumerable source, int chunkSize) - { - if (source is null) - { - throw new ArgumentNullException(nameof(source)); - } - - var buffer = new List(chunkSize); - - foreach (var item in source) - { - buffer.Add(item); - - if (buffer.Count >= chunkSize) - { - yield return buffer; - buffer.Clear(); - } - } - - if (buffer.Count > 0) - { - yield return buffer; - } - } }