priorityqueue
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -13,4 +13,4 @@ "use strict"; | ||
/** | ||
* Constructor of Priority Queue, with the given 'comperator'. | ||
* 'comperator' should be same as Array.prototype.sort's argument. | ||
* Constructor of Priority Queue, with the given 'comparator'. | ||
* 'comparator' should be same as Array.prototype.sort's argument. | ||
* Like this: (a, b) => (a == b ? 0 : (a < b ? -1 : 1)); | ||
@@ -17,0 +17,0 @@ * If not, default function will be passed by PriorityQueue entrypoint. |
@@ -26,7 +26,7 @@ 'use strict'; | ||
options = { | ||
comperator: options | ||
comparator: options | ||
}; | ||
} | ||
options.strategy = options.strategy || PriorityQueue.BinaryHeapStrategy; | ||
options.comperator = options.comperator || function (a, b) { | ||
options.comparator = options.comparator || function (a, b) { | ||
if ([a, b].every(function (x) { | ||
@@ -43,12 +43,12 @@ return typeof x === 'number'; | ||
case PriorityQueue.BinaryHeapStrategy: | ||
return new _BinaryHeapJs2['default'](options.comperator); | ||
return new _BinaryHeapJs2['default'](options.comparator); | ||
break; | ||
case PriorityQueue.SkewHeapStrategy: | ||
return new _SkewHeapJs2['default'](options.comperator); | ||
return new _SkewHeapJs2['default'](options.comparator); | ||
break; | ||
case PriorityQueue.PairingHeapStrategy: | ||
return new _PairingHeapJs2['default'](options.comperator); | ||
return new _PairingHeapJs2['default'](options.comparator); | ||
break; | ||
default: | ||
return new _BinaryHeapJs2['default'](options.comperator); | ||
return new _BinaryHeapJs2['default'](options.comparator); | ||
} | ||
@@ -55,0 +55,0 @@ } |
{ | ||
"name": "priorityqueue", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "An implementation of Priority Queue", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -24,3 +24,3 @@ PriorityQueue | ||
let pq = new PriorityQueue({ | ||
comperator: (a, b)=> | ||
comparator: (a, b)=> | ||
a.x !== b.x ? a.x - b.x : a.y - b.y; | ||
@@ -44,8 +44,8 @@ }); | ||
## PriorityQueue(options = {}) | ||
### options.comperator | ||
`options.comperator` will define an order relation of each values in PriorityQueue. | ||
### options.comparator | ||
`options.comparator` 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. | ||
PriorityQueue with default comparator 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()`. | ||
comparator function format is in according with an argument function of `Array.prototype.sort()`. | ||
@@ -89,3 +89,3 @@ | ||
## peek() | ||
Peeks at the top of the instance in order specified by `options.comperator`. | ||
Peeks at the top of the instance in order specified by `options.comparator`. | ||
@@ -92,0 +92,0 @@ ## pop() |
@@ -93,3 +93,3 @@ import PriorityQueue from '../src/index.js'; | ||
strategy: parseInt(strategy), | ||
comperator: myObjectComp | ||
comparator: myObjectComp | ||
}); | ||
@@ -96,0 +96,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package