Split large Array in Array of two elements
问题 I have large list of objects and I need to split them in a group of two elements for UI propouse. Example: [0, 1, 2, 3, 4, 5, 6] Becomes an array with these four arrays [[0, 1], [2, 3], [4, 5], [6]] There are a ton of ways to split an array. But, what is the most efficient (least costly) if the array is huge. 回答1: If you're looking for efficiency, you could have a method that would generate each array of 2 elements lazily, so you'd only store 2 elements at a time in memory: public struct