Socket
Socket
Sign inDemoInstall

priorityqueue

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.1.0

5

lib/BinaryHeap.js

@@ -123,2 +123,7 @@ "use strict";

}
}, {
key: "length",
get: function get() {
return this.collection.length;
}
}]);

@@ -125,0 +130,0 @@

12

lib/PairingHeap.js

@@ -84,2 +84,3 @@ "use strict";

this.root = null;
this._length = 0;
}

@@ -90,2 +91,3 @@

value: function clear() {
this._length = 0;
this.root = null;

@@ -101,3 +103,3 @@ }

value: function size() {
return count(this.root);
return this._length;
}

@@ -108,2 +110,3 @@ }, {

this.root = merge(this.root, new PairingHeapNode(val), this.comp);
++this._length;
return this;

@@ -121,2 +124,3 @@ }

this.root = mergeList(this.root.head, this.comp);
--this._length;
return ret;

@@ -128,2 +132,3 @@ }

this.root = merge(this.root, other.root, this.comp);
this._length += other.length;
return this;

@@ -141,2 +146,7 @@ }

}
}, {
key: "length",
get: function get() {
return this._length;
}
}]);

@@ -143,0 +153,0 @@

@@ -63,2 +63,3 @@ "use strict";

this.root = null;
this._length = 0;
}

@@ -69,2 +70,3 @@

value: function clear() {
this._length = 0;
this.root = null;

@@ -80,3 +82,3 @@ }

value: function size() {
return count(this.root);
return this._length;
}

@@ -87,2 +89,3 @@ }, {

this.root = _meld(this.root, new SkewHeapNode(val), this.comp);
++this._length;
return this;

@@ -100,2 +103,3 @@ }

this.root = _meld(this.root.right, this.root.left, this.comp);
--this._length;
return ret.value;

@@ -107,2 +111,3 @@ }

this.root = _meld(this.root, other.root, this.comp);
this._length += other.length;
return this;

@@ -120,2 +125,7 @@ }

}
}, {
key: "length",
get: function get() {
return this._length;
}
}]);

@@ -122,0 +132,0 @@

2

package.json
{
"name": "priorityqueue",
"version": "0.0.4",
"version": "0.1.0",
"description": "An implementation of Priority Queue",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -45,5 +45,8 @@ PriorityQueue

`options.comperator` will define an order relation of each values in PriorityQueue.
PriorityQueue with default comperator serves as numerical descending order for numeric values, or lexical descending order for string values.
Comperator function format is in according with an argument function of `Array.prototype.sort()`.
### options.strategy

@@ -55,5 +58,8 @@ - PriorityQueue.BinaryHeapStrategy (default)

All of above strategies are faster than simple implementation such that with `Array.prototype.push() / sort() & pop()`, in the sense of time complexity.
A binary heap is simple(-er than almost other) and has an in-place algorithm and low complexity.
A skew heap and pairing heap are also faster, but these implementation requires using "linked list" structure. Thus, a bit slow. Why these strategies exist? In case of merging queues, time complexity of two each merging is constant time.
API

@@ -60,0 +66,0 @@ ----

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