reduceIndexed

inline fun ByteBuffer.reduceIndexed(operation: (index: Int, acc: Byte, Byte) -> Byte): Byte
inline fun ShortBuffer.reduceIndexed(operation: (index: Int, acc: Short, Short) -> Short): Short
inline fun IntBuffer.reduceIndexed(operation: (index: Int, acc: Int, Int) -> Int): Int
inline fun LongBuffer.reduceIndexed(operation: (index: Int, acc: Long, Long) -> Long): Long
inline fun FloatBuffer.reduceIndexed(operation: (index: Int, acc: Float, Float) -> Float): Float
inline fun DoubleBuffer.reduceIndexed(operation: (index: Int, acc: Double, Double) -> Double): Double
inline fun CharBuffer.reduceIndexed(operation: (index: Int, acc: Char, Char) -> Char): Char

Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element with its index in the original array.

Throws an exception if this array is empty. If the array can be empty in an expected way, please use reduceIndexedOrNull instead. It returns null when its receiver is empty.

Samples

kool.buffers.Collections.Aggregates.reduce

Parameters

operation

function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value.