reduce Indexed
inline fun ByteBuffer.reduceIndexed(operation: (index: Int, acc: Byte, Byte) -> Byte): Byte
Content copied to clipboard
inline fun ShortBuffer.reduceIndexed(operation: (index: Int, acc: Short, Short) -> Short): Short
Content copied to clipboard
inline fun IntBuffer.reduceIndexed(operation: (index: Int, acc: Int, Int) -> Int): Int
Content copied to clipboard
inline fun LongBuffer.reduceIndexed(operation: (index: Int, acc: Long, Long) -> Long): Long
Content copied to clipboard
inline fun FloatBuffer.reduceIndexed(operation: (index: Int, acc: Float, Float) -> Float): Float
Content copied to clipboard
inline fun DoubleBuffer.reduceIndexed(operation: (index: Int, acc: Double, Double) -> Double): Double
Content copied to clipboard
inline fun CharBuffer.reduceIndexed(operation: (index: Int, acc: Char, Char) -> Char): Char
Content copied to clipboard
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.