tiny-binary-heap
Advanced tools
Comparing version 1.0.0 to 1.1.0
21
index.js
@@ -34,2 +34,23 @@ module.exports = class TinyBinaryHeap { | ||
update () { | ||
this._down(1) | ||
} | ||
filter (fn) { // TODO: can prob be done smarter, research | ||
const all = [] | ||
for (let pos = 0; pos < this.heap.length; pos++) { | ||
const val = this.heap[pos] | ||
if (val === undefined) continue | ||
if (fn(val)) all.push(val) | ||
this.heap[pos] = undefined | ||
} | ||
this.length = 0 | ||
for (let i = 0; i < all.length; i++) { | ||
this.push(all[i]) | ||
} | ||
} | ||
_down (pos) { | ||
@@ -36,0 +57,0 @@ const val = this.heap[pos] |
{ | ||
"name": "tiny-binary-heap", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Tiny binary heap with no dependencies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
4737
82