12345678910111213141516171819202122232425 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Bsm.Core
- {
- internal static class ArrayUtil
- {
- public static T[][] SpliceByCount<T>(this T[] source, int count)
- {
- var pieces = new T[(int)Math.Ceiling(source.Length / (float)count)][];
- var idx = 0;
- for (var i = 0; i < source.Length; i += count)
- {
- var buffer = new T[source.Length - i < count ? source.Length - i : count];
- Array.Copy(source, i, buffer, 0, buffer.Length);
- pieces[idx++] = buffer;
- }
- return pieces;
- }
- }
- }
|