Socket
Socket
Sign inDemoInstall

@subsquid/util-internal-binary-heap

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @subsquid/util-internal-binary-heap

Classical implementation of binary heap data structure


Version published
Weekly downloads
2.2K
increased by5.58%
Maintainers
1
Install size
4.11 kB
Created
Weekly downloads
 

Readme

Source

@subsquid/util-internal-binary-heap

Classical implementation of binary heap data structure.

Usage

import {Heap} from "@subsquid/util-internal-binary-heap"

const h = new Heap(function compare(a, b) {
  return a - b
})

h.push(5)
h.push(0)
h.push(10)

h.pop() // => 0
h.pop() // => 5
h.pop() // => 10

h.init([5, 2, 3, 1, 4]) // will modify array in-place and use it as a storage
h.pop() // => 1

h.peek() // => 2
h.size() // => 4

h.resort() // When you have mutable objects,
           // call this to restore heap property after changes

FAQs

Last updated on 01 May 2023

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