### Question:
SparseMatrix extends Matrix { @Override public MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(final int row) { final int[] rowCols = this.cols[row]; final double[] rowValues = this.values[row]; final int maxIndex = this.maxIndices[row]; return new MatrixNonZeroElementRowIterator() { private int index; @Override public boolean hasNext() { return this.index < maxIndex; } @Override public MatrixElement next() { if (!this.hasNext()) { throw new IndexOutOfBoundsException("index out of range"); } return new MatrixElement(row, rowCols[this.index], rowValues[this.index++]); } }; } SparseMatrix(final int numRows, final int numCols, final int initialCapacityPerRow); @Override final void forEach(final ReadOnlyElementVisitorFunction func); @Override MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(final int row); int getNonZeroColumnCount(final int row); int getRowCapacity(final int row); @Override String toString(); int getNumEntries();  }### Answer:
@Test public void setAtUncheckedKeepsColumnsSorted() { final SparseMatrix sparseMatrix = new SparseMatrix(8, 8, 8); sparseMatrix.setAt(0, 7, 5.0); sparseMatrix.setAt(0, 1, 5.0); sparseMatrix.setAt(0, 0, 5.0); sparseMatrix.setAt(0, 5, 5.0); sparseMatrix.setAt(0, 4, 5.0); assertSorted(sparseMatrix.getNonZeroElementRowIterator(0)); }
@Test public void removeKeepsColumnsSorted() { final SparseMatrix sparseMatrix = this.createMatrix(1, 6, new double[] {2, 3, 5, 11, 1, 8}); sparseMatrix.setAt(0, 1, 0.0); sparseMatrix.setAt(0, 4, 0.0); assertSorted(sparseMatrix.getNonZeroElementRowIterator(0)); }
@Test public void removeLessThanKeepsColumnsSorted() { final SparseMatrix sparseMatrix = this.createMatrix(1, 6, new double[] {2, -3, -5, 11, -1, 8}); sparseMatrix.removeLessThan(0); assertSorted(sparseMatrix.getNonZeroElementRowIterator(0)); }