diff --git a/package.json b/package.json index a3d9961..304550d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ml-sparse-matrix", - "version": "0.2.0", + "version": "0.2.1", "description": "Sparse matrix library", "main": "src/SparseMatrix.js", "scripts": { @@ -28,6 +28,6 @@ "should": "^8.3.1" }, "dependencies": { - "ml-hash-table": "^0.1.2" + "ml-hash-table": "^0.2.0" } } diff --git a/src/SparseMatrix.js b/src/SparseMatrix.js index 6b05ff2..4924b26 100644 --- a/src/SparseMatrix.js +++ b/src/SparseMatrix.js @@ -147,13 +147,14 @@ class SparseMatrix { if (this.threshold && Math.abs(r) < this.threshold) r = 0; if (r !== value) { if (r === 0) { - this.elements.remove(key); + this.elements.remove(key, true); } else { this.elements.set(key, r); } } return true; }); + this.elements.maybeShrinkCapacity(); return this; }