sorted-queue
Advanced tools
Comparing version 0.2.0 to 0.3.0
declare type Cmp<T> = (a: T, b: T) => number; | ||
export default class SortedQueue<T> { | ||
export declare class SortedQueue<T> { | ||
private _cmp; | ||
@@ -4,0 +4,0 @@ private _array; |
@@ -1,2 +0,2 @@ | ||
var e=function(e){void 0===e&&(e=i),this._cmp=e,this._array=[]};e.prototype.push=function(e){var t=new r(e,this,this._array.length);return this._array.push(t),function(e,r,t){for(;r._index>0;){var i=e[r._index/2>>>0];if(t(i.value,r.value)<=0)return;n(e,i,r)}}(this._array,t,this._cmp),t},e.prototype.peek=function(){return this._array.length>0?this._array[0]:void 0},e.prototype.pop=function(){var e=this.peek();return e?(e.pop(),e):e};var r=function(e,r,t){this.value=e,this._queue=r,this._index=t};r.prototype.pop=function(){var e=this._queue;if(!e)return!1;var r=e._array.pop();return r&&r!==this&&(r._index=this._index,e._array[this._index]=r,function(e,r,t){for(;;){var i=2*r._index+1,u=i+1;if(u<e.length&&t(e[u].value,r.value)<=0)n(e,e[u],r);else{if(!(i<e.length&&t(e[i].value,r.value)<=0))return;n(e,e[i],r)}}}(e._array,r,e._cmp)),this._queue=null,!0};var t=r;function i(e,r){return e===r?0:e!=e?r!=r?0:-1:r<e||r!=r?1:-1}function n(e,r,t){var i=r._index,n=t._index;e[i]=t,e[n]=r,r._index=n,t._index=i}exports.default=e,exports.SortedQueueItem=t; | ||
var e=function(e){void 0===e&&(e=i),this._cmp=e,this._array=[]};e.prototype.push=function(e){var t=new r(e,this,this._array.length);return this._array.push(t),function(e,r,t){for(;r._index>0;){var i=e[r._index/2>>>0];if(t(i.value,r.value)<=0)return;n(e,i,r)}}(this._array,t,this._cmp),t},e.prototype.peek=function(){return this._array.length>0?this._array[0]:void 0},e.prototype.pop=function(){var e=this.peek();return e?(e.pop(),e):e};var r=function(e,r,t){this.value=e,this._queue=r,this._index=t};r.prototype.pop=function(){var e=this._queue;if(!e)return!1;var r=e._array.pop();return r&&r!==this&&(r._index=this._index,e._array[this._index]=r,function(e,r,t){for(;;){var i=2*r._index+1,u=i+1;if(u<e.length&&t(e[u].value,r.value)<=0)n(e,e[u],r);else{if(!(i<e.length&&t(e[i].value,r.value)<=0))return;n(e,e[i],r)}}}(e._array,r,e._cmp)),this._queue=null,!0};var t=r;function i(e,r){return e===r?0:e!=e?r!=r?0:-1:r<e||r!=r?1:-1}function n(e,r,t){var i=r._index,n=t._index;e[i]=t,e[n]=r,r._index=n,t._index=i}exports.SortedQueue=e,exports.SortedQueueItem=t; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.sortedQueue={})}(this,function(e){var t=function(e){void 0===e&&(e=i),this._cmp=e,this._array=[]};t.prototype.push=function(e){var t=new n(e,this,this._array.length);return this._array.push(t),function(e,t,n){for(;t._index>0;){var r=e[t._index/2>>>0];if(n(r.value,t.value)<=0)return;u(e,r,t)}}(this._array,t,this._cmp),t},t.prototype.peek=function(){return this._array.length>0?this._array[0]:void 0},t.prototype.pop=function(){var e=this.peek();return e?(e.pop(),e):e};var n=function(e,t,n){this.value=e,this._queue=t,this._index=n};n.prototype.pop=function(){var e=this._queue;if(!e)return!1;var t=e._array.pop();return t&&t!==this&&(t._index=this._index,e._array[this._index]=t,function(e,t,n){for(;;){var r=2*t._index+1,i=r+1;if(i<e.length&&n(e[i].value,t.value)<=0)u(e,e[i],t);else{if(!(r<e.length&&n(e[r].value,t.value)<=0))return;u(e,e[r],t)}}}(e._array,t,e._cmp)),this._queue=null,!0};var r=n;function i(e,t){return e===t?0:e!=e?t!=t?0:-1:t<e||t!=t?1:-1}function u(e,t,n){var r=t._index,i=n._index;e[r]=n,e[i]=t,t._index=i,n._index=r}e.default=t,e.SortedQueueItem=r}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.sortedQueue={})}(this,function(e){var t=function(e){void 0===e&&(e=i),this._cmp=e,this._array=[]};t.prototype.push=function(e){var t=new n(e,this,this._array.length);return this._array.push(t),function(e,t,n){for(;t._index>0;){var r=e[t._index/2>>>0];if(n(r.value,t.value)<=0)return;u(e,r,t)}}(this._array,t,this._cmp),t},t.prototype.peek=function(){return this._array.length>0?this._array[0]:void 0},t.prototype.pop=function(){var e=this.peek();return e?(e.pop(),e):e};var n=function(e,t,n){this.value=e,this._queue=t,this._index=n};n.prototype.pop=function(){var e=this._queue;if(!e)return!1;var t=e._array.pop();return t&&t!==this&&(t._index=this._index,e._array[this._index]=t,function(e,t,n){for(;;){var r=2*t._index+1,i=r+1;if(i<e.length&&n(e[i].value,t.value)<=0)u(e,e[i],t);else{if(!(r<e.length&&n(e[r].value,t.value)<=0))return;u(e,e[r],t)}}}(e._array,t,e._cmp)),this._queue=null,!0};var r=n;function i(e,t){return e===t?0:e!=e?t!=t?0:-1:t<e||t!=t?1:-1}function u(e,t,n){var r=t._index,i=n._index;e[r]=n,e[i]=t,t._index=i,n._index=r}e.SortedQueue=t,e.SortedQueueItem=r}); | ||
//# sourceMappingURL=index.umd.js.map |
type Cmp<T> = (a: T, b: T) => number; | ||
export default class SortedQueue<T> { | ||
export class SortedQueue<T> { | ||
private _cmp: Cmp<T>; | ||
@@ -5,0 +5,0 @@ private _array: Array<Item<T>>; |
{ | ||
"name": "sorted-queue", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "A sorted queue, based on an array-backed binary heap", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -14,3 +14,3 @@ # sorted-queue [![npm](https://img.shields.io/npm/v/sorted-queue.svg)](https://www.npmjs.com/package/sorted-queue) | ||
```ts | ||
import SortedQueue from "../index"; | ||
import { SortedQueue } from "sorted-queue"; | ||
@@ -17,0 +17,0 @@ const queue = new SortedQueue(); |
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
24843