JSPM

  • Created
  • Published
  • Downloads 402
  • Score
    100M100P100Q102680F
  • License Apache-2.0

Generic binary heap & d-ary heap implementations with customizable ordering

Package Exports

  • @thi.ng/heaps
  • @thi.ng/heaps/heap

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thi.ng/heaps) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@thi.ng/heaps

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Generic binary heap & d-ary heap implementations 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

Dependencies

API

Generated API docs

import { Heap, DHeap } from "@thi.ng/heaps";

// with initial values, custom comparator and heap arity
const h = new DHeap<number>(
    [5, 2, 10, 15, 18, 23, 22, -1],
    {
        // custom comparator
        compare: (a, b) => b - a,
        // branch size (DHeap only)
        d: 4
    }
);

h.pop();
// 23
h.pop();
// 22

// insert new value unless it's a new root
// else pop and return current root
h.pushPop(16)
// 18

h.push(24);

Authors

Karsten Schmidt

License

© 2017 - 2019 Karsten Schmidt // Apache Software License 2.0