aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/ExtensionMethods
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-21 12:58:15 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-21 12:58:15 +0300
commit7bd70fcb311c808b65b62e774755dcbd6b0d63cd (patch)
tree56db3c489de3665252c44d9ff477bb47bb722dc1 /Software/Visual_Studio/Tango.Core/ExtensionMethods
parentb0255ed4ae2827801d13cec175e57108a0666db9 (diff)
downloadTango-7bd70fcb311c808b65b62e774755dcbd6b0d63cd.tar.gz
Tango-7bd70fcb311c808b65b62e774755dcbd6b0d63cd.zip
Insights anomalies.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods')
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs
new file mode 100644
index 000000000..f3e57b3ea
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+public static class ListExtensions
+{
+ /// <summary>
+ /// Splits the list to chunks.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="source">The source.</param>
+ /// <param name="chunkSize">Size of the chunk.</param>
+ /// <returns></returns>
+ public static List<List<T>> ChunkBy<T>(this List<T> source, int chunkSize)
+ {
+ return source
+ .Select((x, i) => new { Index = i, Value = x })
+ .GroupBy(x => x.Index / chunkSize)
+ .Select(x => x.Select(v => v.Value).ToList())
+ .ToList();
+ }
+}
+