Class

BinaryHeap

:

_items

: T[]

_compareFn

: (a: T, b: T) => boolean

insert

(item: T) => void

Insert an item into the binary heap

remove

() => T | null

Remove the smallest item from the binary heap in case of a min heap or the greatest item from the binary heap in case of a max heap

clear

() => void

Remove all items

moveUp

(pos: number) => void

moveDown

(pos: number) => void

swap

(index1: number, index2: number) => void
get

length

(): number

Returns the amount of items

kaplay logo

Layer

Miscalenous