uchicago.src.sim.space
Class Multi2DHexagonalTorus
java.lang.Object
uchicago.src.sim.space.AbsMulti2DGrid
uchicago.src.sim.space.AbsMulti2DTorus
uchicago.src.sim.space.AbsMulti2DHexagonalTorus
uchicago.src.sim.space.Multi2DHexagonalTorus
- All Implemented Interfaces:
- Discrete2DSpace, IMulti2DGrid, Torus
public class Multi2DHexagonalTorus
- extends AbsMulti2DHexagonalTorus
A torus object that can hold more than one object in its cells.
The cells themselves store their occupants without
any order. Use an OrderedMulti2DTorus if you need
the cell occupants to be stored in an ordered fashion. The object
return by getObjectAt is a BagCell.
The hexagonal cells are referenced by x, y coordinates as follows:
_
_ / 1 \ _
/ 0 \ _ / 2 \
\ _ / 4 \ _ /
/ 3 \ _ / 5 \
\ _ / 7 \ _ /
/ 6 \ _ / 8 \
\ _ / \ _ /
Here we have a 3 x 3 hexagonal grid. The first row of cells is 0,
1, 2 such that 0,0 refers to cell 0, and 0,2 refers to cell 2. The
next row of cells is 3, 4, 5, so 1,0 refers to cell 3 and so
on. The last row of cells is 6, 7, and 8, so 2, 0 refers to cell 6.
The ring of neighbors with radius one that surrounds cell 4 is
composed of 1, 2, 5, 7, 3, and 0. The grid wraps as a toriod such
that cell -1, 0 refers to cell 2 and cell 0, -1 is cell 6.
- Version:
- $Revision: 1.4 $ $Date: 2004/11/03 19:50:58 $
|
Constructor Summary |
Multi2DHexagonalTorus(int xSize,
int ySize,
boolean sparse)
Creates this Multi2DHexagonalTorus with the specified dimensions. |
|
Method Summary |
void |
putObjectAt(int x,
int y,
java.lang.Object object)
Puts the specified Object into the cell at the specified coordinates. |
| Methods inherited from class uchicago.src.sim.space.AbsMulti2DHexagonalTorus |
getMooreNeighbors, getMooreNeighbors, getMooreNeighborsLoc, getMooreNeighborsLoc, getNeighbors, getNeighbors, getNeighborsLoc, getNeighborsLoc, getVNNeighbors, getVNNeighbors, getVNNeighborsLoc, getVNNeighborsLoc |
| Methods inherited from class uchicago.src.sim.space.AbsMulti2DTorus |
clear, getCellAt, getCellSizeAt, getIteratorAt, getMatrix, getObjectAt, getObjectsAt, getValueAt, putValueAt, removeObjectAt, trim, xnorm, ynorm |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Multi2DHexagonalTorus
public Multi2DHexagonalTorus(int xSize,
int ySize,
boolean sparse)
- Creates this Multi2DHexagonalTorus with the specified dimensions.
sparse specifies whether the torus will be sparsely filled or not.
- Parameters:
xSize - the number of columns in the gridySize - the number of rows in the gridsparse - whether the torus will be sparsely populated or not
putObjectAt
public void putObjectAt(int x,
int y,
java.lang.Object object)
- Puts the specified Object into the cell at the specified coordinates.
The contents of the cell are unordered.
- Specified by:
putObjectAt in interface Discrete2DSpace- Specified by:
putObjectAt in class AbsMulti2DTorus
- Parameters:
x - the x coordinatey - the y coordinateobject - the object to put