reduceIndexedOrNull

inline fun ByteBuffer.reduceIndexedOrNull(operation: (index: Int, acc: Byte, Byte) -> Byte): Byte?
inline fun ShortBuffer.reduceIndexedOrNull(operation: (index: Int, acc: Short, Short) -> Short): Short?
inline fun IntBuffer.reduceIndexedOrNull(operation: (index: Int, acc: Int, Int) -> Int): Int?
inline fun LongBuffer.reduceIndexedOrNull(operation: (index: Int, acc: Long, Long) -> Long): Long?
inline fun FloatBuffer.reduceIndexedOrNull(operation: (index: Int, acc: Float, Float) -> Float): Float?
inline fun DoubleBuffer.reduceIndexedOrNull(operation: (index: Int, acc: Double, Double) -> Double): Double?
inline fun CharBuffer.reduceIndexedOrNull(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.

Returns null if the array is empty.

Samples

kool.buffers.Collections.Aggregates.reduceOrNull

Parameters

operation

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