Documentation ¶
Overview ¶
The gopart package alleviates the issue of partitioning collections with wide-ranging types by returning index ranges that can be used on any indexable object. Inspired by Guava's Lists.partition
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Partition ¶
Partition enables type-agnostic partitioning of anything indexable by specifying the length and the desired partition size of the indexable object. Consecutive index ranges are sent to the channel, each of which is the same size. The final range may be smaller than the others.
For example, a collection with length 8 and partition size 3 yields ranges: {0, 3}, {3, 6}, {6, 8}
This method should be used in a for...range loop. No results will be returned if the partition size is nonpositive. If the partition size is greater than the collection length, the range returned includes the entire collection.