edu.umd.cfar.lamp.viper.util
Interface MatrixIterator


public interface MatrixIterator

An iterator for moving through data arranged in a 2-dimensional matrix. To iterate column-by-column, use

 MatrixIterator mi = matrix.getMatrixIterator();
 while (hasNextColumn()) {
     mi.nextColumn();
     while (hasNextInColumn())
         Object data = mi.nextInColumn();
 }
 
 
Alternatively, you can go through each row:
 MatrixIterator mi = matrix.getMatrixIterator();
 while (hasNextRow()) {
     mi.nextRow();
     while (hasNextInRow())
         Object data = mi.nextInRow();
 }
 
 

Author:
David Mihalcik
See Also:
DataMatrix2d

Method Summary
 int currColumn()
          Get the current column offset (x position).
 int currRow()
          Get the current row offset (y position).
 boolean hasNextColumn()
          Checks to see if there is a column to the east.
 boolean hasNextInColumn()
          Is there another item in this column?
 boolean hasNextInRow()
          Is there another item in the current column?
 boolean hasNextRow()
          Checks to see if there is a row to the north.
 int nextColumn()
          Advances to the next column and resets the pointer to the beginning of that column.
 java.lang.Object nextInColumn()
          Returns the next non-empty cell in the matrix in the positive Y direction.
 java.lang.Object nextInRow()
          Returns the next non-empty cell in the matrix in the positive x direction.
 int nextRow()
          Advances to the start of the next non-empty row and returns its index.
 

Method Detail

nextColumn

public int nextColumn()
               throws java.util.NoSuchElementException
Advances to the next column and resets the pointer to the beginning of that column.

Returns:
The column number.
Throws:
java.util.NoSuchElementException - if there is no next column

hasNextColumn

public boolean hasNextColumn()
Checks to see if there is a column to the east.

Returns:
true if iterator has another column.

nextInRow

public java.lang.Object nextInRow()
                           throws java.util.NoSuchElementException
Returns the next non-empty cell in the matrix in the positive x direction.

Returns:
The data stored next along the current row.
Throws:
java.util.NoSuchElementException - if there is no more data in the row.

hasNextInRow

public boolean hasNextInRow()
Is there another item in the current column?

Returns:
true if iterator has another item in this row.

nextRow

public int nextRow()
            throws java.util.NoSuchElementException
Advances to the start of the next non-empty row and returns its index.

Returns:
The row number.
Throws:
java.util.NoSuchElementException - if there is no next row.

hasNextRow

public boolean hasNextRow()
Checks to see if there is a row to the north.

Returns:
true if iterator has another row.

nextInColumn

public java.lang.Object nextInColumn()
                              throws java.util.NoSuchElementException
Returns the next non-empty cell in the matrix in the positive Y direction.

Returns:
The data stored next along the current column.
Throws:
java.util.NoSuchElementException - if there is no more data in the column, or not in a column.

hasNextInColumn

public boolean hasNextInColumn()
Is there another item in this column?

Returns:
true if there is another piece of data along the current column.

currColumn

public int currColumn()
Get the current column offset (x position).

Returns:
The column index.

currRow

public int currRow()
Get the current row offset (y position).

Returns:
The row index.