forEachIndexed

inline fun forEachIndexed(fn: (i: Int, it: T) -> Unit)

Destructively iterates over the elements popped from this heap and calls the given function on each value.

Additionally, the function will be passed an incrementing index value for each element.

Example:

val heap = heapOf(1, 2, 3) { a, b -> a b }

heap.forEachIndexed { i, it -> println("Item $i = $it") }

require(heap.isEmpty())

Parameters

fn

Function to call on each value popped from this heap.