uk.ac.leeds.ccg.andyt.grids.core
Class Grid2DSquareCellAbstract.CellID

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.core.Grid2DSquareCellAbstract.CellID
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable
Enclosing class:
Grid2DSquareCellAbstract

public static class Grid2DSquareCellAbstract.CellID
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

A simple CellID class for distinguishing cells.

See Also:
Serialized Form

Field Summary
protected  long cellColIndex
          For storing the column in which the cell is positioned
protected  long cellRowIndex
          For storing the row in which the cell is positioned
protected  int hashCode
          For storing a hashCode for the cell.
 
Constructor Summary
Grid2DSquareCellAbstract.CellID()
          Default constructor.
Grid2DSquareCellAbstract.CellID(Grid2DSquareCellAbstract.CellID cellID)
          Constructs a new CellID that is a clone of cellID
Grid2DSquareCellAbstract.CellID(long ncols, long cellRowIndex, long cellColIndex)
          Constructs a new CellID
 
Method Summary
 int compareTo(java.lang.Object object)
          Method required by Comparable
 boolean equals(java.lang.Object object)
          Overrides equals in Object
 long getCellColIndex()
          Returns cellColIndex of this CellID
 long getCellRowIndex()
          Returns cellRowIndex of this CellID
 int hashCode()
          Returns hashCode of this CellID
 java.lang.String toString()
          Returns a description of this CellID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

cellRowIndex

protected long cellRowIndex
For storing the row in which the cell is positioned


cellColIndex

protected long cellColIndex
For storing the column in which the cell is positioned


hashCode

protected int hashCode
For storing a hashCode for the cell. NB. When the number of cells in a grid is more than the maximum int value care should be taken that hashCodes are distributed in a relatively even way. Operations will slow down greatly if a large number of cells have a CellID with the same hashCode.

Constructor Detail

Grid2DSquareCellAbstract.CellID

public Grid2DSquareCellAbstract.CellID()
Default constructor.


Grid2DSquareCellAbstract.CellID

public Grid2DSquareCellAbstract.CellID(Grid2DSquareCellAbstract.CellID cellID)
Constructs a new CellID that is a clone of cellID

Parameters:
cellID - The CellID to clone.

Grid2DSquareCellAbstract.CellID

public Grid2DSquareCellAbstract.CellID(long ncols,
                                       long cellRowIndex,
                                       long cellColIndex)
Constructs a new CellID

Parameters:
cellRowIndex - The row of the cell.
cellColIndex - The column of the cell.
ncols - The number of columns in a grid2DSquareCellAbstract.
Method Detail

hashCode

public int hashCode()
Returns hashCode of this CellID

Overrides:
hashCode in class java.lang.Object

getCellRowIndex

public long getCellRowIndex()
Returns cellRowIndex of this CellID


getCellColIndex

public long getCellColIndex()
Returns cellColIndex of this CellID


toString

public java.lang.String toString()
Returns a description of this CellID

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides equals in Object

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object object)
Method required by Comparable

Specified by:
compareTo in interface java.lang.Comparable