|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.space.AbsMulti2DGrid
public abstract class AbsMulti2DGrid
Base class for grids whose cells can hold more that one occupant. The actual object held in the grid cell is a Cell object.
| Field Summary | |
|---|---|
protected BaseMatrix |
matrix
|
protected java.util.Iterator |
roIter
|
protected java.util.List |
roList
|
protected int |
xSize
|
protected int |
ySize
|
| Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace |
|---|
MOORE, VON_NEUMANN |
| Constructor Summary | |
|---|---|
AbsMulti2DGrid(int xSize,
int ySize,
boolean sparse)
Creates this AbsMulti2DGrid with the specified dimensions. |
|
| Method Summary | |
|---|---|
void |
clear(int x,
int y)
Clears the contents the specified cell. |
Cell |
getCellAt(int x,
int y)
Gets the Cell object at the specified coordinates. |
int |
getCellSizeAt(int x,
int y)
Gets the size (number of occupants) of the cell at the specified location. |
java.util.Iterator |
getIteratorAt(int x,
int y)
Gets the iterator for the collection of objects at the specified coordinates. |
BaseMatrix |
getMatrix()
Gets the matrix collection class that contains all the values |
java.util.ArrayList |
getMooreNeighbors(int x,
int y,
boolean returnNulls)
Gets the Moore neighbors of the object(s) at x, y. |
java.util.ArrayList |
getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
Gets the extended Moore neighbors of the object(s) at x, y. |
java.util.ArrayList |
getMooreNeighborsLoc(int x,
int y,
boolean returnNulls)
Gets the Moore neighbors of the object(s) at x, y. |
java.util.ArrayList |
getMooreNeighborsLoc(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
Gets the extended Moore neighbors of the object(s) at x, y. |
java.lang.Object |
getObjectAt(int x,
int y)
Gets the Object at the specified coordinate. |
java.util.List |
getObjectsAt(int x,
int y)
Gets the List of objects at the specified coordinates. |
java.awt.Dimension |
getSize()
Gets the dimension of the space |
int |
getSizeX()
Gets the size of the x dimension |
int |
getSizeY()
Gets the size of the y dimension |
double |
getValueAt(int x,
int y)
Gets the value at the specified coordinate if appropriate. |
java.util.ArrayList |
getVNNeighbors(int x,
int y,
boolean returnNulls)
Gets the von Neumann neighbors of the object(s) at x, y. |
java.util.ArrayList |
getVNNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
Gets the extended von Neumann neighbors of the objects(s) at x, y. |
java.util.ArrayList |
getVNNeighborsLoc(int x,
int y,
boolean returnNulls)
Gets the von Neumann neighbors of the object(s) at x, y. |
java.util.ArrayList |
getVNNeighborsLoc(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
Gets the extended von Neumann neighbors of the objects(s) at x, y. |
abstract void |
putObjectAt(int x,
int y,
java.lang.Object object)
Puts the specified Object at the specified coordinate. |
void |
putValueAt(int x,
int y,
double value)
Puts the specified value at the specified coordinate. |
protected void |
rangeCheck(int x,
int y)
|
void |
removeObjectAt(int x,
int y,
java.lang.Object obj)
Removes the specified object from the specified location. |
void |
trim()
Releases any superfluous memory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected BaseMatrix matrix
protected int xSize
protected int ySize
protected java.util.List roList
protected java.util.Iterator roIter
| Constructor Detail |
|---|
public AbsMulti2DGrid(int xSize,
int ySize,
boolean sparse)
xSize - the number of columns in the gridySize - the number of rows in the gridsparse - whether the grid will be sparsely populated or not| Method Detail |
|---|
protected void rangeCheck(int x,
int y)
public void clear(int x,
int y)
x - the x coordinate of the cell to cleary - the y coordinate of the cell to clear
public java.util.List getObjectsAt(int x,
int y)
getObjectsAt in interface IMulti2DGridx - the x coordinatey - the y coordinate
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.Iterator getIteratorAt(int x,
int y)
getIteratorAt in interface IMulti2DGridx - the x coordinatey - the y coordinate
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public Cell getCellAt(int x,
int y)
getCellAt in interface IMulti2DGridx - the x coordinatey - the y coordinate
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public int getCellSizeAt(int x,
int y)
getCellSizeAt in interface IMulti2DGridx - the x coordinatey - the y coordinate*
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public void removeObjectAt(int x,
int y,
java.lang.Object obj)
removeObjectAt in interface IMulti2DGridx - the x coordinatey - the y coordinateobj - the object to remove
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.ArrayList getVNNeighborsLoc(int x,
int y,
boolean returnNulls)
ObjectLocation objects that can be used to
determined the exact location of the object returned. The objects at x, y
are not returned.
If the neighboring objects contain their location information,
getVNNeighbors(...) should be used as it is faster.
x - the x coordinate of the objecty - the y coordinate of the objectreturnNulls - whether nulls (nothing at x,y) should be returned
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)ObjectLocation
public java.util.ArrayList getVNNeighborsLoc(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
ObjectLocation objects
that can be used to determined the exact location of the object returned.
The objects at x,y are not returned.
If the neighboring objects contain their location information,
getVNNeighbors(...) should be used as it is faster.
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y directionreturnNulls - whether nulls should be returned
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)ObjectLocation
public java.util.ArrayList getMooreNeighborsLoc(int x,
int y,
boolean returnNulls)
ObjectLocation objects that can be used to
determined the exact location of the object returned. The objects at x, y
are not returned. Objects are returned by row starting with the
"NW corner" and ending with the "SE corner."
If the neighboring objects contain their location information,
getMooreNeighbors(...) should be used as it is faster.
x - the x coordinate of the objecty - the y coordinate of the objectreturnNulls - should the returned Vector contain null objects
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)ObjectLocation
public java.util.ArrayList getMooreNeighborsLoc(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
ObjectLocation objects
that can be used to determined the exact location of the object returned.
The objects at x, y are not returned. Objects are returned by
row starting with the "NW corner" and ending with the "SE corner."
If the neighboring objects contain their location information,
getMooreNeighbors(...) should be used as it is faster.
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y directionreturnNulls - should the returned ArrayList contain null objects
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)ObjectLocation
public java.util.ArrayList getVNNeighbors(int x,
int y,
boolean returnNulls)
If the neighboring objects do not contain their location information,
getVNNeighborsLoc(...) can be used, although it is
slower.
x - the x coordinate of the objecty - the y coordinate of the objectreturnNulls - whether nulls (nothing at x,y) should be returned
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.ArrayList getVNNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
If the neighboring objects do not contain their location information,
getVNNeighborsLoc(...) can be used, although it is
slower.
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y directionreturnNulls - whether nulls should be returned
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.ArrayList getMooreNeighbors(int x,
int y,
boolean returnNulls)
If the neighboring objects do not contain their location information,
getMooreNeighborsLoc(...) can be used although it is
slower.
x - the x coordinate of the objecty - the y coordinate of the objectreturnNulls - should the returned ArrayList contain null objects
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.ArrayList getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
If the neighboring objects do not contain their location information,
getMooreNeighborsLoc(...) can be used although it is
slower.
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y directionreturnNulls - should the returned ArrayList contain null objects
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)ObjectLocationpublic int getSizeX()
getSizeX in interface Discrete2DSpacepublic int getSizeY()
getSizeY in interface Discrete2DSpacepublic java.awt.Dimension getSize()
getSize in interface Discrete2DSpace
public java.lang.Object getObjectAt(int x,
int y)
getObjectAt in interface Discrete2DSpacex - the x coordinatey - the y coordinate
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public double getValueAt(int x,
int y)
getValueAt in interface Discrete2DSpacex - the x coordinatey - the y coordinate
public abstract void putObjectAt(int x,
int y,
java.lang.Object object)
putObjectAt in interface Discrete2DSpacex - the x coordinatey - the y coordinateobject - the object to put
public void putValueAt(int x,
int y,
double value)
putValueAt in interface Discrete2DSpacex - the x coordinatey - the y coordinatevalue - the value to put at x,ypublic BaseMatrix getMatrix()
getMatrix in interface Discrete2DSpacepublic void trim()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||