insert

fun insert(value: T)

Inserts a new value into the heap.

If the new value would push the size of the heap to be greater than maxSize an exception will be thrown.

Example:

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

require(heap.peekNext() == 3)

heap.insert(4)

require(heap.peekNext() == 4)

Parameters

value

Value to insert into the heap.

Throws

If inserting a new value would increase the size of the heap to be greater than maxSize.