2.1.2 • Published 1 year ago
@darblast/heap v2.1.2
@darblast/heap
Provides algorithms to manipulate binary heap arrays.
See https://en.wikipedia.org/wiki/Binary_heap for more information.
Three versions of each function are provided:
- the ones suffixed with
Cmp
take an arbitrary comparison function; - the ones suffixed with
Min
use the<
operator and result in a min-heap; - the ones suffixed with
Max
use the>
operator and result in a max-heap.
The comparison function must be the same across calls to different algorithms on the same array, otherwise the results will be inconsistent. It has the following signature:
export type CompareFn<Element> = (lhs: Element, rhs: Element) => boolean;