kmongo / kotlin.collections / com.mongodb.client.MongoIterable / chunked

chunked

fun <T> MongoIterable<T>.chunked(size: Int): List<List<T>> (source)

Splits this collection into a list of lists each not exceeding the given size.

The last list in the resulting list may have less elements than the given size.

//Unresolved: samples.collections.Collections.Transformations.chunked

Parameters

size - the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.

fun <T, R> MongoIterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> (source)

Splits this collection into several lists each not exceeding the given size and applies the given transform function to an each.

//Unresolved: samples.text.Strings.chunkedTransform

Parameters

size - the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.

Return

list of results of the transform applied to an each list.

Note that the list passed to the transform function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it. The last list may have less elements than the given size.