Skip to content

sisobus/MinMaxHeap

Repository files navigation

Min-Max Heap npm version Build Status

Lightweight min-max heap javascript library for node, browser

Install

npm i minmaxheaps

node

const minmaxheaps = require("minmaxheaps")

let mmheap = new minmaxheaps.MinMaxHeap();

mmheap.push(16);
mmheap.push(-5643);
mmheap.popMin();
mmheap.popMax();
mmheap.popMax();
mmheap.push(123);
mmheap.popMin();
console.log(mmheap.heap);
console.log(mmheap.max());
console.log(mmheap.min());

browser

<head>
    <script src="../dist/minmaxheaps.min.js"></script>
    <script>
        const {MinMaxHeap} = minmaxheap;

        let mmheap = new MinMaxHeap();

        mmheap.push(16);
        mmheap.push(-5643);
        mmheap.popMin();
        mmheap.popMax();
        mmheap.popMax();
        mmheap.push(123);
        mmheap.popMin();
        console.log(mmheap.heap);
        console.log(mmheap.max());
        console.log(mmheap.min());
    </script>
</head>

API

  • new MinMaxHeap([duplicate=true, comparator]), where comparator is optional comparison function and duplicate is optional allow duplicate key (default is true)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published