@thi.ng/heaps

This project is part of the
@thi.ng/umbrella monorepo.
About
Various heap implementations for arbitrary values and with customizable ordering.
Type agnostic binary heap & d-ary heap implementations with customizable
ordering and fanout / tree arity (in case of DHeap
). Both Heap
and
DHeap
have an identical base API, however the former provides several
additional operations.
Status
STABLE - used in production
Installation
yarn add @thi.ng/heaps
Package sizes (gzipped): ESM: 1.5KB / CJS: 1.6KB / UMD: 1.7KB
Dependencies
API
Generated API docs
import { Heap, DHeap } from "@thi.ng/heaps";
const h = new DHeap<number>(
[5, 2, 10, 15, 18, 23, 22, -1],
{
compare: (a, b) => b - a,
d: 4
}
);
h.pop();
h.pop();
h.pushPop(16)
h.push(24);
Authors
Karsten Schmidt
License
© 2017 - 2020 Karsten Schmidt // Apache Software License 2.0