cbuffer-resizable
Advanced tools
Comparing version 0.0.2 to 0.0.3
14
index.js
@@ -19,2 +19,3 @@ /** | ||
CBuffer.prototype.constructor.apply(this, Array.prototype.slice.call(arguments)); | ||
this._initialLength = this.length; | ||
this._resizeFactor = 2; // default resize factor is 2 | ||
@@ -67,2 +68,15 @@ }; | ||
CBufferR.prototype.pop = function(){ | ||
var popped = CBuffer.prototype.pop.call(this); | ||
if(this.size << 1 > this._initialLength) { | ||
// shrink array if too big | ||
if (this.size < this.length / (this._resizeFactor * this._resizeFactor)) { | ||
this.resize(this.size << 1); | ||
} | ||
} | ||
return popped; | ||
}; | ||
CBufferR.prototype.swap = function(a, b){ | ||
@@ -69,0 +83,0 @@ var tmp = this.data[a]; |
{ | ||
"author" : "Roberto Sales <robertosalesc@dcc.ufba.br>", | ||
"name": "cbuffer-resizable", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "resizable circular buffer based on CBuffer package", | ||
@@ -6,0 +6,0 @@ "keywords": ["circular buffer", "resizable", "CBuffer", "resize"], |
21634
83