minHeapOf

fun <T : Comparable<T>> minHeapOf(vararg values: T): Heap<T>

Creates a new min-heap containing the given values.

Example:

val heap = minHeapOf(3, 2, 1)

heap.next() // 1
heap.next() // 2
heap.next() // 3

Return

A new Heap instance containing the given values.

Author

Elizabeth Paige Harper - https://github.com/foxcapades

Since

0.1.0

Parameters

values

Values to insert into the created Heap.


fun <T : Comparable<T>> minHeapOf(values: Iterable<T>): Heap<T>

Creates a new min-heap containing the given values.

Example:

val items = listOf(3, 2, 1)
val heap = minHeapOf(items)

heap.next() // 1
heap.next() // 2
heap.next() // 3

Return

A new Heap instance containing the given values.

Author

Elizabeth Paige Harper - https://github.com/foxcapades

Since

0.1.0

Parameters

values

Values to insert into the created Heap.