api / koma.extensions / forEachIndexed

forEachIndexed

@JvmName("forEachIndexedDouble") inline funMatrix<Double>.forEachIndexed(f: (row:Int, col:Int, ele:Double) ->Unit):Unit @JvmName("forEachIndexedFloat") inline funMatrix<Float>.forEachIndexed(f: (row:Int, col:Int, ele:Float) ->Unit):Unit @JvmName("forEachIndexedGeneric") fun <T>Matrix<T>.forEachIndexed(f: (row:Int, col:Int, ele:T) ->Unit):Unit @JvmName("forEachIndexedInt") inline funMatrix<Int>.forEachIndexed(f: (row:Int, col:Int, ele:Int) ->Unit):Unit

Passes each element in row major order into a function along with its index location.

Parameters

f - A function that takes in a row,col position and an element value@JvmName("forEachIndexedByte") inline funNDArray<Byte>.forEachIndexed(f: (idx:Int, ele:Byte) ->Unit):Unit @JvmName("forEachIndexedDouble") inline funNDArray<Double>.forEachIndexed(f: (idx:Int, ele:Double) ->Unit):Unit @JvmName("forEachIndexedFloat") inline funNDArray<Float>.forEachIndexed(f: (idx:Int, ele:Float) ->Unit):Unit @JvmName("forEachIndexedGeneric") fun <T>NDArray<T>.forEachIndexed(f: (idx:Int, ele:T) ->Unit):Unit @JvmName("forEachIndexedInt") inline funNDArray<Int>.forEachIndexed(f: (idx:Int, ele:Int) ->Unit):Unit @JvmName("forEachIndexedLong") inline funNDArray<Long>.forEachIndexed(f: (idx:Int, ele:Long) ->Unit):Unit @JvmName("forEachIndexedShort") inline funNDArray<Short>.forEachIndexed(f: (idx:Int, ele:Short) ->Unit):Unit

Takes each element in a NDArray and passes them through f. Index given to f is a linear index, depending on the underlying storage major dimension.

Parameters

f - A function that takes in an element. Function also takes in the linear index of the element's location.