forEachChunk

inline fun <T> List<T>.forEachChunk(chunkSize: Int, action: (InPlaceSubList<T>) -> Unit)(source)

Iterates through the windowed chunks of this collection with given chunkSize, where window step is equals to chunkSize and calls action on each chunk.

The returned chunk is a view into the original list. Changes in the original list will be reflected in the chunk.

Parameters

chunkSize

the number of elements to take in each window.

action

function that takes the chunk as an argument.