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

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

public static class AbstractGrid2DSquareCell.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
AbstractGrid2DSquareCell.CellID()
          Default constructor.
AbstractGrid2DSquareCell.CellID(AbstractGrid2DSquareCell.CellID _CellID)
          Constructs a new CellID that is a clone of _CellID
AbstractGrid2DSquareCell.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()
           
 long getCellRowIndex()
           
 int hashCode()
           
 java.lang.String toString()
           
 
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

AbstractGrid2DSquareCell.CellID

public AbstractGrid2DSquareCell.CellID()
Default constructor.


AbstractGrid2DSquareCell.CellID

public AbstractGrid2DSquareCell.CellID(AbstractGrid2DSquareCell.CellID _CellID)
Constructs a new CellID that is a clone of _CellID

Parameters:
_CellID - The CellID to clone.

AbstractGrid2DSquareCell.CellID

public AbstractGrid2DSquareCell.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()
Overrides:
hashCode in class java.lang.Object
Returns:
hashCode of this CellID

getCellRowIndex

public long getCellRowIndex()
Returns:
_CellRowIndex of this CellID

getCellColIndex

public long getCellColIndex()
Returns:
_CellColIndex of this CellID

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a description of this CellID

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