1
1
( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . PriorityQueue = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
2
2
var AbstractPriorityQueue , ArrayStrategy , BHeapStrategy , BinaryHeapStrategy , PriorityQueue ,
3
- __hasProp = { } . hasOwnProperty ,
4
- __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 ; } ;
3
+ extend = 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 ; } ,
4
+ hasProp = { } . hasOwnProperty ;
5
5
6
6
AbstractPriorityQueue = require ( './PriorityQueue/AbstractPriorityQueue' ) ;
7
7
@@ -11,8 +11,8 @@ BinaryHeapStrategy = require('./PriorityQueue/BinaryHeapStrategy');
11
11
12
12
BHeapStrategy = require ( './PriorityQueue/BHeapStrategy' ) ;
13
13
14
- PriorityQueue = ( function ( _super ) {
15
- __extends ( PriorityQueue , _super ) ;
14
+ PriorityQueue = ( function ( superClass ) {
15
+ extend ( PriorityQueue , superClass ) ;
16
16
17
17
function PriorityQueue ( options ) {
18
18
options || ( options = { } ) ;
@@ -41,14 +41,15 @@ var AbstractPriorityQueue;
41
41
42
42
module . exports = AbstractPriorityQueue = ( function ( ) {
43
43
function AbstractPriorityQueue ( options ) {
44
+ var ref ;
44
45
if ( ( options != null ? options . strategy : void 0 ) == null ) {
45
46
throw 'Must pass options.strategy, a strategy' ;
46
47
}
47
48
if ( ( options != null ? options . comparator : void 0 ) == null ) {
48
49
throw 'Must pass options.comparator, a comparator' ;
49
50
}
50
51
this . priv = new options . strategy ( options ) ;
51
- this . length = 0 ;
52
+ this . length = ( options != null ? ( ref = options . initialValues ) != null ? ref . length : void 0 : void 0 ) || 0 ;
52
53
}
53
54
54
55
AbstractPriorityQueue . prototype . queue = function ( value ) {
@@ -102,10 +103,10 @@ binarySearchForIndexReversed = function(array, value, comparator) {
102
103
103
104
module . exports = ArrayStrategy = ( function ( ) {
104
105
function ArrayStrategy ( options ) {
105
- var _ref ;
106
+ var ref ;
106
107
this . options = options ;
107
108
this . comparator = this . options . comparator ;
108
- this . data = ( ( _ref = this . options . initialValues ) != null ? _ref . slice ( 0 ) : void 0 ) || [ ] ;
109
+ this . data = ( ( ref = this . options . initialValues ) != null ? ref . slice ( 0 ) : void 0 ) || [ ] ;
109
110
this . data . sort ( this . comparator ) . reverse ( ) ;
110
111
}
111
112
@@ -139,7 +140,7 @@ var BHeapStrategy;
139
140
140
141
module . exports = BHeapStrategy = ( function ( ) {
141
142
function BHeapStrategy ( options ) {
142
- var arr , i , shift , value , _i , _j , _len , _ref , _ref1 ;
143
+ var arr , i , j , k , len , ref , ref1 , shift , value ;
143
144
this . comparator = ( options != null ? options . comparator : void 0 ) || function ( a , b ) {
144
145
return a - b ;
145
146
} ;
@@ -154,15 +155,15 @@ module.exports = BHeapStrategy = (function() {
154
155
}
155
156
this . _shift = shift ;
156
157
this . _emptyMemoryPageTemplate = arr = [ ] ;
157
- for ( i = _i = 0 , _ref = this . pageSize ; 0 <= _ref ? _i < _ref : _i > _ref ; i = 0 <= _ref ? ++ _i : -- _i ) {
158
+ for ( i = j = 0 , ref = this . pageSize ; 0 <= ref ? j < ref : j > ref ; i = 0 <= ref ? ++ j : -- j ) {
158
159
arr . push ( null ) ;
159
160
}
160
161
this . _memory = [ ] ;
161
162
this . _mask = this . pageSize - 1 ;
162
163
if ( options . initialValues ) {
163
- _ref1 = options . initialValues ;
164
- for ( _j = 0 , _len = _ref1 . length ; _j < _len ; _j ++ ) {
165
- value = _ref1 [ _j ] ;
164
+ ref1 = options . initialValues ;
165
+ for ( k = 0 , len = ref1 . length ; k < len ; k ++ ) {
166
+ value = ref1 [ k ] ;
166
167
this . queue ( value ) ;
167
168
}
168
169
}
@@ -290,19 +291,19 @@ var BinaryHeapStrategy;
290
291
291
292
module . exports = BinaryHeapStrategy = ( function ( ) {
292
293
function BinaryHeapStrategy ( options ) {
293
- var _ref ;
294
+ var ref ;
294
295
this . comparator = ( options != null ? options . comparator : void 0 ) || function ( a , b ) {
295
296
return a - b ;
296
297
} ;
297
298
this . length = 0 ;
298
- this . data = ( ( _ref = options . initialValues ) != null ? _ref . slice ( 0 ) : void 0 ) || [ ] ;
299
+ this . data = ( ( ref = options . initialValues ) != null ? ref . slice ( 0 ) : void 0 ) || [ ] ;
299
300
this . _heapify ( ) ;
300
301
}
301
302
302
303
BinaryHeapStrategy . prototype . _heapify = function ( ) {
303
- var i , _i , _ref ;
304
+ var i , j , ref ;
304
305
if ( this . data . length > 0 ) {
305
- for ( i = _i = 1 , _ref = this . data . length ; 1 <= _ref ? _i < _ref : _i > _ref ; i = 1 <= _ref ? ++ _i : -- _i ) {
306
+ for ( i = j = 1 , ref = this . data . length ; 1 <= ref ? j < ref : j > ref ; i = 1 <= ref ? ++ j : -- j ) {
306
307
this . _bubbleUp ( i ) ;
307
308
}
308
309
}
0 commit comments