js-priority-queue
Advanced tools
Comparing version 0.0.4 to 0.0.5
(function() { | ||
var __hasProp = {}.hasOwnProperty, | ||
var define, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(['./PriorityQueue/AbstractPriorityQueue', './PriorityQueue/ArrayStrategy', './PriorityQueue/BinaryHeapStrategy', './PriorityQueue/BHeapStrategy'], function(AbstractPriorityQueue, ArrayStrategy, BinaryHeapStrategy, BHeapStrategy) { | ||
@@ -6,0 +11,0 @@ var PriorityQueue; |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(function() { | ||
@@ -3,0 +9,0 @@ var AbstractPriorityQueue; |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(function() { | ||
@@ -3,0 +9,0 @@ var ArrayStrategy, binarySearchForIndexReversed; |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(function() { | ||
@@ -3,0 +9,0 @@ var BHeapStrategy; |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(function() { | ||
@@ -3,0 +9,0 @@ var BinaryHeapStrategy; |
{ | ||
"name": "js-priority-queue", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Priority queue data structures", | ||
"main": "priority-queue.js", | ||
"main": "index.js", | ||
"scripts": {}, | ||
@@ -29,4 +29,5 @@ "repository": { | ||
"grunt-template-jasmine-requirejs": "~0.1.3", | ||
"grunt-requirejs": "~0.3.5" | ||
"grunt-requirejs": "~0.3.5", | ||
"amdefine": "~0.1.0" | ||
} | ||
} |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/AbstractPriorityQueue',[],function() { | ||
@@ -49,2 +55,8 @@ var AbstractPriorityQueue; | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/ArrayStrategy',[],function() { | ||
@@ -101,2 +113,8 @@ var ArrayStrategy, binarySearchForIndexReversed; | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/BinaryHeapStrategy',[],function() { | ||
@@ -198,2 +216,8 @@ var BinaryHeapStrategy; | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/BHeapStrategy',[],function() { | ||
@@ -349,5 +373,10 @@ var BHeapStrategy; | ||
(function() { | ||
var __hasProp = {}.hasOwnProperty, | ||
var define, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue',['./PriorityQueue/AbstractPriorityQueue', './PriorityQueue/ArrayStrategy', './PriorityQueue/BinaryHeapStrategy', './PriorityQueue/BHeapStrategy'], function(AbstractPriorityQueue, ArrayStrategy, BinaryHeapStrategy, BHeapStrategy) { | ||
@@ -354,0 +383,0 @@ var PriorityQueue; |
@@ -1,1 +0,1 @@ | ||
!function(){define("PriorityQueue/AbstractPriorityQueue",[],function(){var t;return t=function(){function t(t){if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=0}return t.prototype.queue=function(t){return this.length++,this.priv.queue(t),void 0},t.prototype.dequeue=function(){if(!this.length)throw"Empty queue";return this.length--,this.priv.dequeue()},t.prototype.peek=function(){if(!this.length)throw"Empty queue";return this.priv.peek()},t}()})}.call(this),function(){define("PriorityQueue/ArrayStrategy",[],function(){var t,i;return i=function(t,i,e){var r,a,o;for(a=0,r=t.length;r>a;)o=a+r>>>1,e(t[o],i)>=0?a=o+1:r=o;return a},t=function(){function t(t){var i;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(i=this.options.initialValues)?i.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var e;return e=i(this.data,t,this.comparator),this.data.splice(e,0,t),void 0},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t}()})}.call(this),function(){define("PriorityQueue/BinaryHeapStrategy",[],function(){var t;return t=function(){function t(t){var i;this.comparator=(null!=t?t.comparator:void 0)||function(t,i){return t-i},this.length=0,this.data=(null!=(i=t.initialValues)?i.slice(0):void 0)||[],this._heapify()}return t.prototype._heapify=function(){var t,i,e;if(this.data.length>0)for(t=i=1,e=this.data.length;e>=1?e>i:i>e;t=e>=1?++i:--i)this._bubbleUp(t);return void 0},t.prototype.queue=function(t){return this.data.push(t),this._bubbleUp(this.data.length-1),void 0},t.prototype.dequeue=function(){var t,i;return i=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),i},t.prototype.peek=function(){return this.data[0]},t.prototype._bubbleUp=function(t){for(var i,e;t>0&&(i=t-1>>>1,this.comparator(this.data[t],this.data[i])<0);)e=this.data[i],this.data[i]=this.data[t],this.data[t]=e,t=i;return void 0},t.prototype._bubbleDown=function(t){var i,e,r,a,o;for(i=this.data.length-1;;){if(e=(t<<1)+1,a=e+1,r=t,i>=e&&this.comparator(this.data[e],this.data[r])<0&&(r=e),i>=a&&this.comparator(this.data[a],this.data[r])<0&&(r=a),r===t)break;o=this.data[r],this.data[r]=this.data[t],this.data[t]=o,t=r}return void 0},t}()})}.call(this),function(){define("PriorityQueue/BHeapStrategy",[],function(){var t;return t=function(){function t(t){var i,e,r,a,o,n,s,h,u;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,i){return t-i},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,r=0;1<<r<this.pageSize;)r+=1;if(1<<r!==this.pageSize)throw"pageSize must be a power of two";for(this._shift=r,this._emptyMemoryPageTemplate=i=[],e=o=0,h=this.pageSize;h>=0?h>o:o>h;e=h>=0?++o:--o)i.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(u=t.initialValues,n=0,s=u.length;s>n;n++)a=u[n],this.queue(a)}return t.prototype.queue=function(t){return this.length+=1,this._write(this.length,t),this._bubbleUp(this.length,t),void 0},t.prototype.dequeue=function(){var t,i;return t=this._read(1),i=this._read(this.length),this.length-=1,this.length>0&&(this._write(1,i),this._bubbleDown(1,i)),t},t.prototype.peek=function(){return this._read(1)},t.prototype._write=function(t,i){var e;for(e=t>>this._shift;e>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[e][t&this._mask]=i},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,i){var e,r,a,o;for(e=this.comparator;t>1&&(r=t&this._mask,t<this.pageSize||r>3?a=t&~this._mask|r>>1:2>r?(a=t-this.pageSize>>this._shift,a+=a&~(this._mask>>1),a|=this.pageSize>>1):a=t-2,o=this._read(a),!(e(o,i)<0));)this._write(a,i),this._write(t,o),t=a;return void 0},t.prototype._bubbleDown=function(t,i){var e,r,a,o,n;for(n=this.comparator;t<this.length;)if(t>this._mask&&!(t&this._mask-1)?e=r=t+2:t&this.pageSize>>1?(e=(t&~this._mask)>>1,e|=t&this._mask>>1,e=e+1<<this._shift,r=e+1):(e=t+(t&this._mask),r=e+1),e!==r&&r<=this.length)if(a=this._read(e),o=this._read(r),n(a,i)<0&&n(a,o)<=0)this._write(e,i),this._write(t,a),t=e;else{if(!(n(o,i)<0))break;this._write(r,i),this._write(t,o),t=r}else{if(!(e<=this.length))break;if(a=this._read(e),!(n(a,i)<0))break;this._write(e,i),this._write(t,a),t=e}return void 0},t}()})}.call(this),function(){var t={}.hasOwnProperty,i=function(i,e){function r(){this.constructor=i}for(var a in e)t.call(e,a)&&(i[a]=e[a]);return r.prototype=e.prototype,i.prototype=new r,i.__super__=e.prototype,i};define("PriorityQueue",["./PriorityQueue/AbstractPriorityQueue","./PriorityQueue/ArrayStrategy","./PriorityQueue/BinaryHeapStrategy","./PriorityQueue/BHeapStrategy"],function(t,e,r,a){var o;return o=function(t){function e(t){t||(t={}),t.strategy||(t.strategy=r),t.comparator||(t.comparator=function(t,i){return(t||0)-(i||0)}),e.__super__.constructor.call(this,t)}return i(e,t),e}(t),o.ArrayStrategy=e,o.BinaryHeapStrategy=r,o.BHeapStrategy=a,o})}.call(this); | ||
!function(){var t;("undefined"==typeof t||null===t)&&(t=require("amdefine")(module)),t("PriorityQueue/AbstractPriorityQueue",[],function(){var t;return t=function(){function t(t){if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=0}return t.prototype.queue=function(t){return this.length++,this.priv.queue(t),void 0},t.prototype.dequeue=function(){if(!this.length)throw"Empty queue";return this.length--,this.priv.dequeue()},t.prototype.peek=function(){if(!this.length)throw"Empty queue";return this.priv.peek()},t}()})}.call(this),function(){var t;("undefined"==typeof t||null===t)&&(t=require("amdefine")(module)),t("PriorityQueue/ArrayStrategy",[],function(){var t,e;return e=function(t,e,i){var r,a,o;for(a=0,r=t.length;r>a;)o=a+r>>>1,i(t[o],e)>=0?a=o+1:r=o;return a},t=function(){function t(t){var e;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(e=this.options.initialValues)?e.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var i;return i=e(this.data,t,this.comparator),this.data.splice(i,0,t),void 0},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t}()})}.call(this),function(){var t;("undefined"==typeof t||null===t)&&(t=require("amdefine")(module)),t("PriorityQueue/BinaryHeapStrategy",[],function(){var t;return t=function(){function t(t){var e;this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.length=0,this.data=(null!=(e=t.initialValues)?e.slice(0):void 0)||[],this._heapify()}return t.prototype._heapify=function(){var t,e,i;if(this.data.length>0)for(t=e=1,i=this.data.length;i>=1?i>e:e>i;t=i>=1?++e:--e)this._bubbleUp(t);return void 0},t.prototype.queue=function(t){return this.data.push(t),this._bubbleUp(this.data.length-1),void 0},t.prototype.dequeue=function(){var t,e;return e=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),e},t.prototype.peek=function(){return this.data[0]},t.prototype._bubbleUp=function(t){for(var e,i;t>0&&(e=t-1>>>1,this.comparator(this.data[t],this.data[e])<0);)i=this.data[e],this.data[e]=this.data[t],this.data[t]=i,t=e;return void 0},t.prototype._bubbleDown=function(t){var e,i,r,a,o;for(e=this.data.length-1;;){if(i=(t<<1)+1,a=i+1,r=t,e>=i&&this.comparator(this.data[i],this.data[r])<0&&(r=i),e>=a&&this.comparator(this.data[a],this.data[r])<0&&(r=a),r===t)break;o=this.data[r],this.data[r]=this.data[t],this.data[t]=o,t=r}return void 0},t}()})}.call(this),function(){var t;("undefined"==typeof t||null===t)&&(t=require("amdefine")(module)),t("PriorityQueue/BHeapStrategy",[],function(){var t;return t=function(){function t(t){var e,i,r,a,o,n,s,u,h;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,r=0;1<<r<this.pageSize;)r+=1;if(1<<r!==this.pageSize)throw"pageSize must be a power of two";for(this._shift=r,this._emptyMemoryPageTemplate=e=[],i=o=0,u=this.pageSize;u>=0?u>o:o>u;i=u>=0?++o:--o)e.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(h=t.initialValues,n=0,s=h.length;s>n;n++)a=h[n],this.queue(a)}return t.prototype.queue=function(t){return this.length+=1,this._write(this.length,t),this._bubbleUp(this.length,t),void 0},t.prototype.dequeue=function(){var t,e;return t=this._read(1),e=this._read(this.length),this.length-=1,this.length>0&&(this._write(1,e),this._bubbleDown(1,e)),t},t.prototype.peek=function(){return this._read(1)},t.prototype._write=function(t,e){var i;for(i=t>>this._shift;i>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[i][t&this._mask]=e},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,e){var i,r,a,o;for(i=this.comparator;t>1&&(r=t&this._mask,t<this.pageSize||r>3?a=t&~this._mask|r>>1:2>r?(a=t-this.pageSize>>this._shift,a+=a&~(this._mask>>1),a|=this.pageSize>>1):a=t-2,o=this._read(a),!(i(o,e)<0));)this._write(a,e),this._write(t,o),t=a;return void 0},t.prototype._bubbleDown=function(t,e){var i,r,a,o,n;for(n=this.comparator;t<this.length;)if(t>this._mask&&!(t&this._mask-1)?i=r=t+2:t&this.pageSize>>1?(i=(t&~this._mask)>>1,i|=t&this._mask>>1,i=i+1<<this._shift,r=i+1):(i=t+(t&this._mask),r=i+1),i!==r&&r<=this.length)if(a=this._read(i),o=this._read(r),n(a,e)<0&&n(a,o)<=0)this._write(i,e),this._write(t,a),t=i;else{if(!(n(o,e)<0))break;this._write(r,e),this._write(t,o),t=r}else{if(!(i<=this.length))break;if(a=this._read(i),!(n(a,e)<0))break;this._write(i,e),this._write(t,a),t=i}return void 0},t}()})}.call(this),function(){var t,e={}.hasOwnProperty,i=function(t,i){function r(){this.constructor=t}for(var a in i)e.call(i,a)&&(t[a]=i[a]);return r.prototype=i.prototype,t.prototype=new r,t.__super__=i.prototype,t};("undefined"==typeof t||null===t)&&(t=require("amdefine")(module)),t("PriorityQueue",["./PriorityQueue/AbstractPriorityQueue","./PriorityQueue/ArrayStrategy","./PriorityQueue/BinaryHeapStrategy","./PriorityQueue/BHeapStrategy"],function(t,e,r,a){var o;return o=function(t){function e(t){t||(t={}),t.strategy||(t.strategy=r),t.comparator||(t.comparator=function(t,e){return(t||0)-(e||0)}),e.__super__.constructor.call(this,t)}return i(e,t),e}(t),o.ArrayStrategy=e,o.BinaryHeapStrategy=r,o.BHeapStrategy=a,o})}.call(this); |
@@ -411,2 +411,8 @@ (function () { | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/AbstractPriorityQueue',[],function() { | ||
@@ -458,2 +464,8 @@ var AbstractPriorityQueue; | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/ArrayStrategy',[],function() { | ||
@@ -510,2 +522,8 @@ var ArrayStrategy, binarySearchForIndexReversed; | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/BinaryHeapStrategy',[],function() { | ||
@@ -607,2 +625,8 @@ var BinaryHeapStrategy; | ||
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue/BHeapStrategy',[],function() { | ||
@@ -758,5 +782,10 @@ var BHeapStrategy; | ||
(function() { | ||
var __hasProp = {}.hasOwnProperty, | ||
var define, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define('PriorityQueue',['./PriorityQueue/AbstractPriorityQueue', './PriorityQueue/ArrayStrategy', './PriorityQueue/BinaryHeapStrategy', './PriorityQueue/BHeapStrategy'], function(AbstractPriorityQueue, ArrayStrategy, BinaryHeapStrategy, BHeapStrategy) { | ||
@@ -763,0 +792,0 @@ var PriorityQueue; |
@@ -7,2 +7,2 @@ /** | ||
!function(){var t,i,e;!function(r){function n(t,i){return b.call(t,i)}function o(t,i){var e,r,n,o,a,s,u,h,p,f,l=i&&i.split("/"),c=m.map,y=c&&c["*"]||{};if(t&&"."===t.charAt(0))if(i){for(l=l.slice(0,l.length-1),t=l.concat(t.split("/")),h=0;h<t.length;h+=1)if(f=t[h],"."===f)t.splice(h,1),h-=1;else if(".."===f){if(1===h&&(".."===t[2]||".."===t[0]))break;h>0&&(t.splice(h-1,2),h-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((l||y)&&c){for(e=t.split("/"),h=e.length;h>0;h-=1){if(r=e.slice(0,h).join("/"),l)for(p=l.length;p>0;p-=1)if(n=c[l.slice(0,p).join("/")],n&&(n=n[r])){o=n,a=h;break}if(o)break;!s&&y&&y[r]&&(s=y[r],u=h)}!o&&s&&(o=s,a=u),o&&(e.splice(0,a,o),t=e.join("/"))}return t}function a(t,i){return function(){return c.apply(r,w.call(arguments,0).concat([t,i]))}}function s(t){return function(i){return o(i,t)}}function u(t){return function(i){g[t]=i}}function h(t){if(n(_,t)){var i=_[t];delete _[t],v[t]=!0,l.apply(r,i)}if(!n(g,t)&&!n(v,t))throw new Error("No "+t);return g[t]}function p(t){var i,e=t?t.indexOf("!"):-1;return e>-1&&(i=t.substring(0,e),t=t.substring(e+1,t.length)),[i,t]}function f(t){return function(){return m&&m.config&&m.config[t]||{}}}var l,c,y,d,g={},_={},m={},v={},b=Object.prototype.hasOwnProperty,w=[].slice;y=function(t,i){var e,r=p(t),n=r[0];return t=r[1],n&&(n=o(n,i),e=h(n)),n?t=e&&e.normalize?e.normalize(t,s(i)):o(t,i):(t=o(t,i),r=p(t),n=r[0],t=r[1],n&&(e=h(n))),{f:n?n+"!"+t:t,n:t,pr:n,p:e}},d={require:function(t){return a(t)},exports:function(t){var i=g[t];return"undefined"!=typeof i?i:g[t]={}},module:function(t){return{id:t,uri:"",exports:g[t],config:f(t)}}},l=function(t,i,e,o){var s,p,f,l,c,m,b=[];if(o=o||t,"function"==typeof e){for(i=!i.length&&e.length?["require","exports","module"]:i,c=0;c<i.length;c+=1)if(l=y(i[c],o),p=l.f,"require"===p)b[c]=d.require(t);else if("exports"===p)b[c]=d.exports(t),m=!0;else if("module"===p)s=b[c]=d.module(t);else if(n(g,p)||n(_,p)||n(v,p))b[c]=h(p);else{if(!l.p)throw new Error(t+" missing "+p);l.p.load(l.n,a(o,!0),u(p),{}),b[c]=g[p]}f=e.apply(g[t],b),t&&(s&&s.exports!==r&&s.exports!==g[t]?g[t]=s.exports:f===r&&m||(g[t]=f))}else t&&(g[t]=e)},t=i=c=function(t,i,e,n,o){return"string"==typeof t?d[t]?d[t](i):h(y(t,i).f):(t.splice||(m=t,i.splice?(t=i,i=e,e=null):t=r),i=i||function(){},"function"==typeof e&&(e=n,n=o),n?l(r,t,i,e):setTimeout(function(){l(r,t,i,e)},4),c)},c.config=function(t){return m=t,m.deps&&c(m.deps,m.callback),c},e=function(t,i,e){i.splice||(e=i,i=[]),n(g,t)||n(_,t)||(_[t]=[t,i,e])},e.amd={jQuery:!0}}(),e("almond",function(){}),function(){e("PriorityQueue/AbstractPriorityQueue",[],function(){var t;return t=function(){function t(t){if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=0}return t.prototype.queue=function(t){return this.length++,this.priv.queue(t),void 0},t.prototype.dequeue=function(){if(!this.length)throw"Empty queue";return this.length--,this.priv.dequeue()},t.prototype.peek=function(){if(!this.length)throw"Empty queue";return this.priv.peek()},t}()})}.call(this),function(){e("PriorityQueue/ArrayStrategy",[],function(){var t,i;return i=function(t,i,e){var r,n,o;for(n=0,r=t.length;r>n;)o=n+r>>>1,e(t[o],i)>=0?n=o+1:r=o;return n},t=function(){function t(t){var i;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(i=this.options.initialValues)?i.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var e;return e=i(this.data,t,this.comparator),this.data.splice(e,0,t),void 0},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t}()})}.call(this),function(){e("PriorityQueue/BinaryHeapStrategy",[],function(){var t;return t=function(){function t(t){var i;this.comparator=(null!=t?t.comparator:void 0)||function(t,i){return t-i},this.length=0,this.data=(null!=(i=t.initialValues)?i.slice(0):void 0)||[],this._heapify()}return t.prototype._heapify=function(){var t,i,e;if(this.data.length>0)for(t=i=1,e=this.data.length;e>=1?e>i:i>e;t=e>=1?++i:--i)this._bubbleUp(t);return void 0},t.prototype.queue=function(t){return this.data.push(t),this._bubbleUp(this.data.length-1),void 0},t.prototype.dequeue=function(){var t,i;return i=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),i},t.prototype.peek=function(){return this.data[0]},t.prototype._bubbleUp=function(t){for(var i,e;t>0&&(i=t-1>>>1,this.comparator(this.data[t],this.data[i])<0);)e=this.data[i],this.data[i]=this.data[t],this.data[t]=e,t=i;return void 0},t.prototype._bubbleDown=function(t){var i,e,r,n,o;for(i=this.data.length-1;;){if(e=(t<<1)+1,n=e+1,r=t,i>=e&&this.comparator(this.data[e],this.data[r])<0&&(r=e),i>=n&&this.comparator(this.data[n],this.data[r])<0&&(r=n),r===t)break;o=this.data[r],this.data[r]=this.data[t],this.data[t]=o,t=r}return void 0},t}()})}.call(this),function(){e("PriorityQueue/BHeapStrategy",[],function(){var t;return t=function(){function t(t){var i,e,r,n,o,a,s,u,h;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,i){return t-i},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,r=0;1<<r<this.pageSize;)r+=1;if(1<<r!==this.pageSize)throw"pageSize must be a power of two";for(this._shift=r,this._emptyMemoryPageTemplate=i=[],e=o=0,u=this.pageSize;u>=0?u>o:o>u;e=u>=0?++o:--o)i.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(h=t.initialValues,a=0,s=h.length;s>a;a++)n=h[a],this.queue(n)}return t.prototype.queue=function(t){return this.length+=1,this._write(this.length,t),this._bubbleUp(this.length,t),void 0},t.prototype.dequeue=function(){var t,i;return t=this._read(1),i=this._read(this.length),this.length-=1,this.length>0&&(this._write(1,i),this._bubbleDown(1,i)),t},t.prototype.peek=function(){return this._read(1)},t.prototype._write=function(t,i){var e;for(e=t>>this._shift;e>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[e][t&this._mask]=i},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,i){var e,r,n,o;for(e=this.comparator;t>1&&(r=t&this._mask,t<this.pageSize||r>3?n=t&~this._mask|r>>1:2>r?(n=t-this.pageSize>>this._shift,n+=n&~(this._mask>>1),n|=this.pageSize>>1):n=t-2,o=this._read(n),!(e(o,i)<0));)this._write(n,i),this._write(t,o),t=n;return void 0},t.prototype._bubbleDown=function(t,i){var e,r,n,o,a;for(a=this.comparator;t<this.length;)if(t>this._mask&&!(t&this._mask-1)?e=r=t+2:t&this.pageSize>>1?(e=(t&~this._mask)>>1,e|=t&this._mask>>1,e=e+1<<this._shift,r=e+1):(e=t+(t&this._mask),r=e+1),e!==r&&r<=this.length)if(n=this._read(e),o=this._read(r),a(n,i)<0&&a(n,o)<=0)this._write(e,i),this._write(t,n),t=e;else{if(!(a(o,i)<0))break;this._write(r,i),this._write(t,o),t=r}else{if(!(e<=this.length))break;if(n=this._read(e),!(a(n,i)<0))break;this._write(e,i),this._write(t,n),t=e}return void 0},t}()})}.call(this),function(){var t={}.hasOwnProperty,i=function(i,e){function r(){this.constructor=i}for(var n in e)t.call(e,n)&&(i[n]=e[n]);return r.prototype=e.prototype,i.prototype=new r,i.__super__=e.prototype,i};e("PriorityQueue",["./PriorityQueue/AbstractPriorityQueue","./PriorityQueue/ArrayStrategy","./PriorityQueue/BinaryHeapStrategy","./PriorityQueue/BHeapStrategy"],function(t,e,r,n){var o;return o=function(t){function e(t){t||(t={}),t.strategy||(t.strategy=r),t.comparator||(t.comparator=function(t,i){return(t||0)-(i||0)}),e.__super__.constructor.call(this,t)}return i(e,t),e}(t),o.ArrayStrategy=e,o.BinaryHeapStrategy=r,o.BHeapStrategy=n,o})}.call(this),function(){i(["./PriorityQueue"],function(t){return window.PriorityQueue=t})}.call(this),e("index",function(){})}(); | ||
!function(){var t,e,i;!function(r){function n(t,e){return b.call(t,e)}function o(t,e){var i,r,n,o,a,u,s,h,p,f,l=e&&e.split("/"),c=_.map,d=c&&c["*"]||{};if(t&&"."===t.charAt(0))if(e){for(l=l.slice(0,l.length-1),t=l.concat(t.split("/")),h=0;h<t.length;h+=1)if(f=t[h],"."===f)t.splice(h,1),h-=1;else if(".."===f){if(1===h&&(".."===t[2]||".."===t[0]))break;h>0&&(t.splice(h-1,2),h-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((l||d)&&c){for(i=t.split("/"),h=i.length;h>0;h-=1){if(r=i.slice(0,h).join("/"),l)for(p=l.length;p>0;p-=1)if(n=c[l.slice(0,p).join("/")],n&&(n=n[r])){o=n,a=h;break}if(o)break;!u&&d&&d[r]&&(u=d[r],s=h)}!o&&u&&(o=u,a=s),o&&(i.splice(0,a,o),t=i.join("/"))}return t}function a(t,e){return function(){return c.apply(r,w.call(arguments,0).concat([t,e]))}}function u(t){return function(e){return o(e,t)}}function s(t){return function(e){m[t]=e}}function h(t){if(n(g,t)){var e=g[t];delete g[t],v[t]=!0,l.apply(r,e)}if(!n(m,t)&&!n(v,t))throw new Error("No "+t);return m[t]}function p(t){var e,i=t?t.indexOf("!"):-1;return i>-1&&(e=t.substring(0,i),t=t.substring(i+1,t.length)),[e,t]}function f(t){return function(){return _&&_.config&&_.config[t]||{}}}var l,c,d,y,m={},g={},_={},v={},b=Object.prototype.hasOwnProperty,w=[].slice;d=function(t,e){var i,r=p(t),n=r[0];return t=r[1],n&&(n=o(n,e),i=h(n)),n?t=i&&i.normalize?i.normalize(t,u(e)):o(t,e):(t=o(t,e),r=p(t),n=r[0],t=r[1],n&&(i=h(n))),{f:n?n+"!"+t:t,n:t,pr:n,p:i}},y={require:function(t){return a(t)},exports:function(t){var e=m[t];return"undefined"!=typeof e?e:m[t]={}},module:function(t){return{id:t,uri:"",exports:m[t],config:f(t)}}},l=function(t,e,i,o){var u,p,f,l,c,_,b=[];if(o=o||t,"function"==typeof i){for(e=!e.length&&i.length?["require","exports","module"]:e,c=0;c<e.length;c+=1)if(l=d(e[c],o),p=l.f,"require"===p)b[c]=y.require(t);else if("exports"===p)b[c]=y.exports(t),_=!0;else if("module"===p)u=b[c]=y.module(t);else if(n(m,p)||n(g,p)||n(v,p))b[c]=h(p);else{if(!l.p)throw new Error(t+" missing "+p);l.p.load(l.n,a(o,!0),s(p),{}),b[c]=m[p]}f=i.apply(m[t],b),t&&(u&&u.exports!==r&&u.exports!==m[t]?m[t]=u.exports:f===r&&_||(m[t]=f))}else t&&(m[t]=i)},t=e=c=function(t,e,i,n,o){return"string"==typeof t?y[t]?y[t](e):h(d(t,e).f):(t.splice||(_=t,e.splice?(t=e,e=i,i=null):t=r),e=e||function(){},"function"==typeof i&&(i=n,n=o),n?l(r,t,e,i):setTimeout(function(){l(r,t,e,i)},4),c)},c.config=function(t){return _=t,_.deps&&c(_.deps,_.callback),c},i=function(t,e,i){e.splice||(i=e,e=[]),n(m,t)||n(g,t)||(g[t]=[t,e,i])},i.amd={jQuery:!0}}(),i("almond",function(){}),function(){var t;("undefined"==typeof t||null===t)&&(t=e("amdefine")(module)),t("PriorityQueue/AbstractPriorityQueue",[],function(){var t;return t=function(){function t(t){if(null==(null!=t?t.strategy:void 0))throw"Must pass options.strategy, a strategy";if(null==(null!=t?t.comparator:void 0))throw"Must pass options.comparator, a comparator";this.priv=new t.strategy(t),this.length=0}return t.prototype.queue=function(t){return this.length++,this.priv.queue(t),void 0},t.prototype.dequeue=function(){if(!this.length)throw"Empty queue";return this.length--,this.priv.dequeue()},t.prototype.peek=function(){if(!this.length)throw"Empty queue";return this.priv.peek()},t}()})}.call(this),function(){var t;("undefined"==typeof t||null===t)&&(t=e("amdefine")(module)),t("PriorityQueue/ArrayStrategy",[],function(){var t,e;return e=function(t,e,i){var r,n,o;for(n=0,r=t.length;r>n;)o=n+r>>>1,i(t[o],e)>=0?n=o+1:r=o;return n},t=function(){function t(t){var e;this.options=t,this.comparator=this.options.comparator,this.data=(null!=(e=this.options.initialValues)?e.slice(0):void 0)||[],this.data.sort(this.comparator).reverse()}return t.prototype.queue=function(t){var i;return i=e(this.data,t,this.comparator),this.data.splice(i,0,t),void 0},t.prototype.dequeue=function(){return this.data.pop()},t.prototype.peek=function(){return this.data[this.data.length-1]},t}()})}.call(this),function(){var t;("undefined"==typeof t||null===t)&&(t=e("amdefine")(module)),t("PriorityQueue/BinaryHeapStrategy",[],function(){var t;return t=function(){function t(t){var e;this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.length=0,this.data=(null!=(e=t.initialValues)?e.slice(0):void 0)||[],this._heapify()}return t.prototype._heapify=function(){var t,e,i;if(this.data.length>0)for(t=e=1,i=this.data.length;i>=1?i>e:e>i;t=i>=1?++e:--e)this._bubbleUp(t);return void 0},t.prototype.queue=function(t){return this.data.push(t),this._bubbleUp(this.data.length-1),void 0},t.prototype.dequeue=function(){var t,e;return e=this.data[0],t=this.data.pop(),this.data.length>0&&(this.data[0]=t,this._bubbleDown(0)),e},t.prototype.peek=function(){return this.data[0]},t.prototype._bubbleUp=function(t){for(var e,i;t>0&&(e=t-1>>>1,this.comparator(this.data[t],this.data[e])<0);)i=this.data[e],this.data[e]=this.data[t],this.data[t]=i,t=e;return void 0},t.prototype._bubbleDown=function(t){var e,i,r,n,o;for(e=this.data.length-1;;){if(i=(t<<1)+1,n=i+1,r=t,e>=i&&this.comparator(this.data[i],this.data[r])<0&&(r=i),e>=n&&this.comparator(this.data[n],this.data[r])<0&&(r=n),r===t)break;o=this.data[r],this.data[r]=this.data[t],this.data[t]=o,t=r}return void 0},t}()})}.call(this),function(){var t;("undefined"==typeof t||null===t)&&(t=e("amdefine")(module)),t("PriorityQueue/BHeapStrategy",[],function(){var t;return t=function(){function t(t){var e,i,r,n,o,a,u,s,h;for(this.comparator=(null!=t?t.comparator:void 0)||function(t,e){return t-e},this.pageSize=(null!=t?t.pageSize:void 0)||512,this.length=0,r=0;1<<r<this.pageSize;)r+=1;if(1<<r!==this.pageSize)throw"pageSize must be a power of two";for(this._shift=r,this._emptyMemoryPageTemplate=e=[],i=o=0,s=this.pageSize;s>=0?s>o:o>s;i=s>=0?++o:--o)e.push(null);if(this._memory=[],this._mask=this.pageSize-1,t.initialValues)for(h=t.initialValues,a=0,u=h.length;u>a;a++)n=h[a],this.queue(n)}return t.prototype.queue=function(t){return this.length+=1,this._write(this.length,t),this._bubbleUp(this.length,t),void 0},t.prototype.dequeue=function(){var t,e;return t=this._read(1),e=this._read(this.length),this.length-=1,this.length>0&&(this._write(1,e),this._bubbleDown(1,e)),t},t.prototype.peek=function(){return this._read(1)},t.prototype._write=function(t,e){var i;for(i=t>>this._shift;i>=this._memory.length;)this._memory.push(this._emptyMemoryPageTemplate.slice(0));return this._memory[i][t&this._mask]=e},t.prototype._read=function(t){return this._memory[t>>this._shift][t&this._mask]},t.prototype._bubbleUp=function(t,e){var i,r,n,o;for(i=this.comparator;t>1&&(r=t&this._mask,t<this.pageSize||r>3?n=t&~this._mask|r>>1:2>r?(n=t-this.pageSize>>this._shift,n+=n&~(this._mask>>1),n|=this.pageSize>>1):n=t-2,o=this._read(n),!(i(o,e)<0));)this._write(n,e),this._write(t,o),t=n;return void 0},t.prototype._bubbleDown=function(t,e){var i,r,n,o,a;for(a=this.comparator;t<this.length;)if(t>this._mask&&!(t&this._mask-1)?i=r=t+2:t&this.pageSize>>1?(i=(t&~this._mask)>>1,i|=t&this._mask>>1,i=i+1<<this._shift,r=i+1):(i=t+(t&this._mask),r=i+1),i!==r&&r<=this.length)if(n=this._read(i),o=this._read(r),a(n,e)<0&&a(n,o)<=0)this._write(i,e),this._write(t,n),t=i;else{if(!(a(o,e)<0))break;this._write(r,e),this._write(t,o),t=r}else{if(!(i<=this.length))break;if(n=this._read(i),!(a(n,e)<0))break;this._write(i,e),this._write(t,n),t=i}return void 0},t}()})}.call(this),function(){var t,i={}.hasOwnProperty,r=function(t,e){function r(){this.constructor=t}for(var n in e)i.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};("undefined"==typeof t||null===t)&&(t=e("amdefine")(module)),t("PriorityQueue",["./PriorityQueue/AbstractPriorityQueue","./PriorityQueue/ArrayStrategy","./PriorityQueue/BinaryHeapStrategy","./PriorityQueue/BHeapStrategy"],function(t,e,i,n){var o;return o=function(t){function e(t){t||(t={}),t.strategy||(t.strategy=i),t.comparator||(t.comparator=function(t,e){return(t||0)-(e||0)}),e.__super__.constructor.call(this,t)}return r(e,t),e}(t),o.ArrayStrategy=e,o.BinaryHeapStrategy=i,o.BHeapStrategy=n,o})}.call(this),function(){e(["./PriorityQueue"],function(t){return window.PriorityQueue=t})}.call(this),i("index",function(){})}(); |
@@ -32,7 +32,7 @@ Priority Queue | ||
require([ 'vendor/priority-queue' ], function(PriorityQueue) { | ||
var queue = new PriorityQueue({ comparator: function(a, b) { return b - a; }); | ||
var queue = new PriorityQueue({ comparator: function(a, b) { return b - a; }}); | ||
queue.queue(5); | ||
queue.queue(3); | ||
queue.queue(2); | ||
var lowest = queue.pop(); // returns 2 | ||
var lowest = queue.dequeue(); // returns 5 | ||
}); | ||
@@ -43,7 +43,7 @@ | ||
var queue = new PriorityQueue({ comparator: function(a, b) { return b - a; }); | ||
var queue = new PriorityQueue({ comparator: function(a, b) { return b - a; }}); | ||
queue.queue(5); | ||
queue.queue(3); | ||
queue.queue(2); | ||
var lowest = queue.pop(); // returns 2 | ||
var lowest = queue.dequeue(); // returns 5 | ||
@@ -50,0 +50,0 @@ Options |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(['PriorityQueue/AbstractPriorityQueue'], function(AbstractPriorityQueue) { | ||
@@ -3,0 +9,0 @@ var numberCompare; |
(function() { | ||
var define; | ||
if (typeof define === "undefined" || define === null) { | ||
define = require('amdefine')(module); | ||
} | ||
define(['PriorityQueue'], function(PriorityQueue) { | ||
@@ -3,0 +9,0 @@ var numberCompare; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
104177
41
1713
6
3