2.1.2 • Published 3 years 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
Cmptake an arbitrary comparison function; - the ones suffixed with
Minuse the<operator and result in a min-heap; - the ones suffixed with
Maxuse 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;