class 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++]);
      }
    };
  }

  public  SparseMatrix(final int numRows, final int numCols, final int initialCapacityPerRow);

}