priority-queues
v1.0.0
Published
priority queue(heap) data structure for node.js and browsers
Downloads
2
Maintainers
Readme
priority-queues
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