for Each Indexed
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())Content copied to clipboard
Parameters
fn
Function to call on each value popped from this heap.