New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stablepriorityqueue

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stablepriorityqueue - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.travis.yml

7

package.json
{
"name": "stablepriorityqueue",
"version": "0.1.0",
"version": "0.1.1",
"description": "A stable heap-based priority queue in JavaScript",

@@ -14,3 +14,6 @@ "main": "StablePriorityQueue.js",

"keywords": [
"heap", "binary heap", "data structure", "priority queue"
"heap",
"binary heap",
"data structure",
"priority queue"
],

@@ -17,0 +20,0 @@ "author": "Daniel Lemire <lemire@gmail.com> (http://lemire.me/en/)",

# StablePriorityQueue.js
[![Build Status](https://travis-ci.org/lemire/StablePriorityQueue.js.svg?branch=master)](https://travis-ci.org/lemire/StablePriorityQueue.js)
A stable heap-based priority queue in JavaScript
A heap can be used to implement a priority queue. At all times, you can insert
elements quickly in a heap, and query the smallest element. You remove (poll)
the smallest element quickly as well.
In a priority queue, you can...
- query or remove (poll) the smallest element quickly
- insert elements quickly
In practice, "quickly" often means in logarithmic time (O(log n)).
A heap can be used to implement a priority queue.
StablePriorityQueue is an attempt to implement a priority queue

@@ -9,0 +16,0 @@ in JavaScript that is stable. That is, when equal values are inserted, it will always poll the oldest of the equal values.

@@ -56,3 +56,3 @@ /**

while(! this.isEmpty() ) {
buffer.push(this.poll().value);
buffer.push(this.poll());
}

@@ -59,0 +59,0 @@ size = buffer.length;

@@ -25,2 +25,16 @@ /* This script expects node.js and mocha */

});
it('issue3', function() {
var queue = new StablePriorityQueue(function(a, b) {
return b - a;
});
for (var i = 0; i < 10; ++i) {
queue.add(i);
}
queue.renumber();
var counter = 9;
while (!queue.isEmpty()) {
if(queue.poll() != counter) throw "bug";
counter--;
}
});
it('is_stable', function() {

@@ -27,0 +41,0 @@ var x = new StablePriorityQueue(function(a, b) {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc