Socket
Book a DemoInstallSign in
Socket

heap-dot-js

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heap-dot-js

Efficient and useful implementation of the heap structure

1.0.5
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Contributors Forks Stargazers Issues LinkedIn


Heap Dot Js

About The Project

Efficient and useful implementation of the heap structure

Getting Started

yarn add heap-dot-js # if you use yarn

npm install --save heap-dot-js # if you use npm

Usage

// Basic usage example
import Heap from 'heap-dot-js';

const minHeap = new MinHeap();
minHeap.buildHeap([2, 3, 4, 5, -2, 56, 6, 1]);
console.log(minHeap.values); //[-2, 1, 4, 2, 3, 56, 6, 5]
minHeap.add(-12);
console.log(minHeap.values); //[-12, -2, 1, 4, 2, 3, 56, 6, 5]
console.log(minHeap.removeTop()); //-12
console.log(minHeap.values); //[-2, 1, 4, 2, 3, 56, 6, 5]

const maxHeap = new MaxHeap();
maxHeap.buildHeap([2, 3, 4, 5, -2, 56, 6, 1]);
console.log(maxHeap.values); //[56, 5, 6, 3, -2, 4, 2, 1]
maxHeap.add(86); 
console.log(maxHeap.values); //[86, 56, 5, 6, 3, -2, 4, 2, 1, -12]
console.log(maxHeap.removeTop()); //86
console.log(maxHeap.values); //[56, 5, 6, 3, -2, 4, 2, 1]

Keywords

heap

FAQs

Package last updated on 21 Oct 2021

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.