diff --git a/lib/binary_heap.js b/lib/binary_heap.js index 68ed13c..06a4285 100644 --- a/lib/binary_heap.js +++ b/lib/binary_heap.js @@ -11,11 +11,8 @@ var BinaryHeap = module.exports = function BinaryHeap(scoreFunction){ BinaryHeap.prototype = { - clone: function() { - var heap = new BinaryHeap(this.scoreFunction); - // A little hacky, but effective. - heap.content = JSON.parse(JSON.stringify(this.content)); - return heap; + getValues: function() { + return this.content; }, push: function(element) { diff --git a/stats/exponentially_decaying_sample.js b/stats/exponentially_decaying_sample.js index 75931fd..9586840 100644 --- a/stats/exponentially_decaying_sample.js +++ b/stats/exponentially_decaying_sample.js @@ -14,15 +14,9 @@ var ExponentiallyDecayingSample = module.exports = function ExponentiallyDecayin ExponentiallyDecayingSample.prototype = new Sample(); -// This is a relatively expensive operation +// The result is not sorted in a meaningful order. ExponentiallyDecayingSample.prototype.getValues = function() { - var values = [] - , elt - , heap = this.values.clone(); - while(elt = heap.pop()) { - values.push(elt.val); - } - return values; + return this.values.getValues().map(function(v) { return v.val; }); } ExponentiallyDecayingSample.prototype.size = function() {