priority-queues

1.0.0 • Public • Published

priority-queues

Build Status

priority queue using heap data structure

Usage

Example

  var PQueue = require('priority-queues')
  
  p = new PQueue()
  
  // push elements into the queue
  p.push(4)
  p.push(2)
  p.push(1)
 
  //pop elements out of the queue
  p.pop() //1
  p.pop() //2
  p.pop() //4

API

p = new PQueue([arr])

create new instance of priority queue. If arr given then creates the heap using this array otherwise empty queue

p.push(element)

pushes element into the heap structure

p.pop()

pops the first element(minimum one) from the heap structure

d.size()

returns the number of elements in the queue

p.isEmpty()

returns true if the queue is empty

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i priority-queues

Weekly Downloads

10

Version

1.0.0

License

MIT

Last publish

Collaborators

  • incessantmeraki