|
1 | 1 | /*!
|
2 | 2 | * angular-cache
|
3 |
| - * @version 4.3.1 - Homepage <http://jmdobry.github.io/angular-cache/> |
| 3 | + * @version 4.3.2 - Homepage <http://jmdobry.github.io/angular-cache/> |
4 | 4 | * @author Jason Dobry <[email protected]>
|
5 | 5 | * @copyright (c) 2013-2015 Jason Dobry
|
6 | 6 | * @license MIT <https://github.com/jmdobry/angular-cache/blob/master/LICENSE>
|
@@ -108,7 +108,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
108 | 108 |
|
109 | 109 | /*!
|
110 | 110 | * cachefactory
|
111 |
| - * @version 1.0.2 - Homepage <http://jmdobry.github.io/cachefactory/> |
| 111 | + * @version 1.1.0 - Homepage <http://jmdobry.github.io/cachefactory/> |
112 | 112 | * @author Jason Dobry <[email protected]>
|
113 | 113 | * @copyright (c) 2013-2015 Jason Dobry
|
114 | 114 | * @license MIT <https://github.com/jmdobry/cachefactory/blob/master/LICENSE>
|
@@ -1085,7 +1085,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
1085 | 1085 |
|
1086 | 1086 | /*!
|
1087 | 1087 | * yabh
|
1088 |
| - * @version 1.0.1 - Homepage <http://jmdobry.github.io/yabh/> |
| 1088 | + * @version 1.1.0 - Homepage <http://jmdobry.github.io/yabh/> |
1089 | 1089 | * @author Jason Dobry <[email protected]>
|
1090 | 1090 | * @copyright (c) 2015 Jason Dobry
|
1091 | 1091 | * @license MIT <https://github.com/jmdobry/yabh/blob/master/LICENSE>
|
@@ -1148,13 +1148,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
1148 | 1148 | /* 0 */
|
1149 | 1149 | /***/ function(module, exports, __webpack_require__) {
|
1150 | 1150 |
|
1151 |
| - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; |
1152 |
| - |
1153 |
| - var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); |
1154 |
| - |
1155 |
| - Object.defineProperty(exports, '__esModule', { |
1156 |
| - value: true |
1157 |
| - }); |
1158 | 1151 | /**
|
1159 | 1152 | * @method bubbleUp
|
1160 | 1153 | * @param {array} heap The heap.
|
@@ -1223,88 +1216,75 @@ return /******/ (function(modules) { // webpackBootstrap
|
1223 | 1216 | }
|
1224 | 1217 | };
|
1225 | 1218 |
|
1226 |
| - var BinaryHeap = (function () { |
1227 |
| - function BinaryHeap(weightFunc, compareFunc) { |
1228 |
| - _classCallCheck(this, BinaryHeap); |
| 1219 | + function BinaryHeap(weightFunc, compareFunc) { |
| 1220 | + if (!weightFunc) { |
| 1221 | + weightFunc = function (x) { |
| 1222 | + return x; |
| 1223 | + }; |
| 1224 | + } |
| 1225 | + if (!compareFunc) { |
| 1226 | + compareFunc = function (x, y) { |
| 1227 | + return x === y; |
| 1228 | + }; |
| 1229 | + } |
| 1230 | + if (typeof weightFunc !== 'function') { |
| 1231 | + throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!'); |
| 1232 | + } |
| 1233 | + if (typeof compareFunc !== 'function') { |
| 1234 | + throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!'); |
| 1235 | + } |
| 1236 | + this.weightFunc = weightFunc; |
| 1237 | + this.compareFunc = compareFunc; |
| 1238 | + this.heap = []; |
| 1239 | + } |
| 1240 | + |
| 1241 | + var BHProto = BinaryHeap.prototype; |
1229 | 1242 |
|
1230 |
| - if (!weightFunc) { |
1231 |
| - weightFunc = function (x) { |
1232 |
| - return x; |
1233 |
| - }; |
1234 |
| - } |
1235 |
| - if (!compareFunc) { |
1236 |
| - compareFunc = function (x, y) { |
1237 |
| - return x === y; |
1238 |
| - }; |
1239 |
| - } |
1240 |
| - if (typeof weightFunc !== 'function') { |
1241 |
| - throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!'); |
1242 |
| - } |
1243 |
| - if (typeof compareFunc !== 'function') { |
1244 |
| - throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!'); |
1245 |
| - } |
1246 |
| - this.weightFunc = weightFunc; |
1247 |
| - this.compareFunc = compareFunc; |
1248 |
| - this.heap = []; |
| 1243 | + BHProto.push = function (node) { |
| 1244 | + this.heap.push(node); |
| 1245 | + bubbleUp(this.heap, this.weightFunc, this.heap.length - 1); |
| 1246 | + }; |
| 1247 | + |
| 1248 | + BHProto.peek = function () { |
| 1249 | + return this.heap[0]; |
| 1250 | + }; |
| 1251 | + |
| 1252 | + BHProto.pop = function () { |
| 1253 | + var front = this.heap[0]; |
| 1254 | + var end = this.heap.pop(); |
| 1255 | + if (this.heap.length > 0) { |
| 1256 | + this.heap[0] = end; |
| 1257 | + bubbleDown(this.heap, this.weightFunc, 0); |
1249 | 1258 | }
|
| 1259 | + return front; |
| 1260 | + }; |
1250 | 1261 |
|
1251 |
| - _createClass(BinaryHeap, [{ |
1252 |
| - key: 'push', |
1253 |
| - value: function push(node) { |
1254 |
| - this.heap.push(node); |
1255 |
| - bubbleUp(this.heap, this.weightFunc, this.heap.length - 1); |
1256 |
| - } |
1257 |
| - }, { |
1258 |
| - key: 'peek', |
1259 |
| - value: function peek() { |
1260 |
| - return this.heap[0]; |
1261 |
| - } |
1262 |
| - }, { |
1263 |
| - key: 'pop', |
1264 |
| - value: function pop() { |
1265 |
| - var front = this.heap[0]; |
| 1262 | + BHProto.remove = function (node) { |
| 1263 | + var length = this.heap.length; |
| 1264 | + for (var i = 0; i < length; i++) { |
| 1265 | + if (this.compareFunc(this.heap[i], node)) { |
| 1266 | + var removed = this.heap[i]; |
1266 | 1267 | var end = this.heap.pop();
|
1267 |
| - if (this.heap.length > 0) { |
1268 |
| - this.heap[0] = end; |
1269 |
| - bubbleDown(this.heap, this.weightFunc, 0); |
1270 |
| - } |
1271 |
| - return front; |
1272 |
| - } |
1273 |
| - }, { |
1274 |
| - key: 'remove', |
1275 |
| - value: function remove(node) { |
1276 |
| - var length = this.heap.length; |
1277 |
| - for (var i = 0; i < length; i++) { |
1278 |
| - if (this.compareFunc(this.heap[i], node)) { |
1279 |
| - var removed = this.heap[i]; |
1280 |
| - var end = this.heap.pop(); |
1281 |
| - if (i !== length - 1) { |
1282 |
| - this.heap[i] = end; |
1283 |
| - bubbleUp(this.heap, this.weightFunc, i); |
1284 |
| - bubbleDown(this.heap, this.weightFunc, i); |
1285 |
| - } |
1286 |
| - return removed; |
1287 |
| - } |
| 1268 | + if (i !== length - 1) { |
| 1269 | + this.heap[i] = end; |
| 1270 | + bubbleUp(this.heap, this.weightFunc, i); |
| 1271 | + bubbleDown(this.heap, this.weightFunc, i); |
1288 | 1272 | }
|
1289 |
| - return null; |
| 1273 | + return removed; |
1290 | 1274 | }
|
1291 |
| - }, { |
1292 |
| - key: 'removeAll', |
1293 |
| - value: function removeAll() { |
1294 |
| - this.heap = []; |
1295 |
| - } |
1296 |
| - }, { |
1297 |
| - key: 'size', |
1298 |
| - value: function size() { |
1299 |
| - return this.heap.length; |
1300 |
| - } |
1301 |
| - }]); |
| 1275 | + } |
| 1276 | + return null; |
| 1277 | + }; |
1302 | 1278 |
|
1303 |
| - return BinaryHeap; |
1304 |
| - })(); |
| 1279 | + BHProto.removeAll = function () { |
| 1280 | + this.heap = []; |
| 1281 | + }; |
| 1282 | + |
| 1283 | + BHProto.size = function () { |
| 1284 | + return this.heap.length; |
| 1285 | + }; |
1305 | 1286 |
|
1306 |
| - exports['default'] = BinaryHeap; |
1307 |
| - module.exports = exports['default']; |
| 1287 | + module.exports = BinaryHeap; |
1308 | 1288 |
|
1309 | 1289 | /***/ }
|
1310 | 1290 | /******/ ])
|
|
0 commit comments