MATES 3.0-rc2

org.mates.util
Class Grid

java.lang.Object
  extended byorg.mates.util.Grid

public class Grid
extends java.lang.Object

A class for storing objects in a grid or matrix.

Author:
Evan Sultanik

Constructor Summary
Grid()
          Creates a grid with one row and one column.
Grid(int num_rows, int num_columns)
          Creates a grid.
 
Method Summary
 void clear()
          Removes all of the elements from the grid.
 boolean columnIsFuzzy(java.lang.Object object)
          Returns whether the current column is definite or "fuzzy".
 int getColumn(java.lang.Object object)
          Returns the column of an object in the grid.
 int getNumColumns()
          Returns the current number of columns in the grid.
 int getNumRows()
          Returns the current number of rows in the grid.
 int getRow(java.lang.Object object)
          Returns the row of an object in the grid.
 void put(int row, int column, java.lang.Object object)
          Inserts a new element into this grid.
 void remove(java.lang.Object object)
          Removes an element from the grid.
 boolean rowIsFuzzy(java.lang.Object object)
          Returns whether the current row is definite or "fuzzy".
 void setColFuzzy(java.lang.Object object, boolean fuzzy)
          Sets the fuzzy state of an object's column.
 void setNumColumns(int new_num_columns)
          Sets the number of columns in the grid.
 void setNumRows(int new_num_rows)
          Sets the number of rows in the grid.
 void setRowFuzzy(java.lang.Object object, boolean fuzzy)
          Sets the fuzzy state of an object's row.
 int size()
          Returns the number of elements in the grid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grid

public Grid()
Creates a grid with one row and one column.


Grid

public Grid(int num_rows,
            int num_columns)
Creates a grid.

Parameters:
num_rows - the number of rows for this grid
num_columns - the number of columns for this grid
Method Detail

put

public void put(int row,
                int column,
                java.lang.Object object)
Inserts a new element into this grid. If the element already exists in the grid, the element is moved to the new location.

Parameters:
row - the row of the object
column - the column of the object
object - the object to be inserted or moved

rowIsFuzzy

public boolean rowIsFuzzy(java.lang.Object object)
Returns whether the current row is definite or "fuzzy".

Returns:
true if and only if the current object's row is fuzzy. Returns false if the object is not in the grid.

columnIsFuzzy

public boolean columnIsFuzzy(java.lang.Object object)
Returns whether the current column is definite or "fuzzy".

Returns:
true if and only if the current object's column is fuzzy. Returns false if the object is not in the grid.

setRowFuzzy

public void setRowFuzzy(java.lang.Object object,
                        boolean fuzzy)
Sets the fuzzy state of an object's row. A row or column is "fuzzy" if it is not necessarily definite. This method has no effect if the object is not in the grid.


setColFuzzy

public void setColFuzzy(java.lang.Object object,
                        boolean fuzzy)
Sets the fuzzy state of an object's column. A row or column is "fuzzy" if it is not necessarily definite. This method has no effect if the object is not in the grid.


getRow

public int getRow(java.lang.Object object)
Returns the row of an object in the grid.

Returns:
the row associated with object; -1 on error.

getColumn

public int getColumn(java.lang.Object object)
Returns the column of an object in the grid.

Returns:
the column associated with object; -1 on error.

getNumRows

public int getNumRows()
Returns the current number of rows in the grid.


getNumColumns

public int getNumColumns()
Returns the current number of columns in the grid.


size

public int size()
Returns the number of elements in the grid.


clear

public void clear()
Removes all of the elements from the grid.


setNumRows

public void setNumRows(int new_num_rows)
Sets the number of rows in the grid. If the new number of rows is smaller than the previous number of rows, any elements in an invalidated row are moved to the largest row.


setNumColumns

public void setNumColumns(int new_num_columns)
Sets the number of columns in the grid. If the new number of columns is smaller than the previous number of columns, any elements in an invalidated column are moved to the largest column.


remove

public void remove(java.lang.Object object)
Removes an element from the grid.


MATES 3.0-rc2

Submit a bug or request a feature
http://mates.sourceforge.net/

Copyright 2004 Evan Sultanik