Min Heap
val heap = minHeapOf(1, 5, 2, 4, 3)
require(heap.next() == 1)
require(heap.next() == 2)
require(heap.next() == 3)
require(heap.next() == 4)
require(heap.next() == 5)
Max Heap
val heap = maxHeapOf(1, 5, 2, 4, 3)
require(heap.next() == 5)
require(heap.next() == 4)
require(heap.next() == 3)
require(heap.next() == 2)
require(heap.next() == 1)
data class Dog(val name: String)
val dogs = listOf(
Dog("Dexter"),
Dog("Luna"),
Dog("Daisy"),
Dog("Max"),
)
val heap = heapOf(dogs) { a, b -> a.name < b.name}