Socket
Socket
Sign inDemoInstall

min-heap

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    min-heap

min-heap data structure


Version published
Weekly downloads
65
increased by490.91%
Maintainers
1
Install size
4.93 kB
Created
Weekly downloads
 

Readme

Source

min-heap

API

var MinHeap = require('min-heap');

var heap = new MinHeap;
heap.insert(5);
heap.insert(1);
heap.insert(3);
heap.insert(2);

heap.removeHead(); // => 1
heap.removeHead(); // => 2
heap.removeHead(); // => 3
heap.removeHead(); // => 5

User-defined comparison function

// Pass user-defined comparison function as first param
var heap = new MinHeap(function(l,r) {
    return l.weight - r.weight;
});

heap.insert({weight: 1, id: "spaghetti"});
heap.insert({weight: 3, id: "courgettes"});

heap.removeHead(); // => {weight: 1, id: "spaghetti"}

Keywords

FAQs

Last updated on 02 Aug 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc