public abstract class AbstractGrid2D extends java.lang.Object implements Grid2D
Grid2D foo = ... ; foo.tx(4); // will not get inlined AbstractGrid2D bar = ...; bar.tx(4); // WILL get inlined ObjectGrid2D baz = ...; // (assuming we're an ObjectGrid2D) baz.tx(4); // WILL get inlined
Modifier and Type  Field and Description 

protected int 
height 
protected int 
width 
Constructor and Description 

AbstractGrid2D() 
Modifier and Type  Method and Description 

java.util.Map 
buildMap(int size)
Creates a map of the provided size (or any size it likes if ANY_SIZE is passed in).

java.util.Map 
buildMap(java.util.Map other)
Creates a Map which is a copy of another.

protected void 
checkBounds(Grid2D other) 
int 
dlx(int x,
int y)
Hex downleft x.

int 
dly(int x,
int y)
Hex downleft y.

int 
downx(int x,
int y)
Hex down x.

int 
downy(int x,
int y)
Hex down y.

int 
drx(int x,
int y)
Hex downright x.

int 
dry(int x,
int y)
Hex downright y.

int 
getHeight()
Returns the width of the field.

void 
getHexagonalLocations(int x,
int y,
int dist,
int mode,
boolean includeOrigin,
IntBag xPos,
IntBag yPos)
Gets all neighbors located within the hexagon centered at (X,Y) and 2*dist+1 cells from point to opposite point
inclusive.

void 
getMooreLocations(int x,
int y,
int dist,
int mode,
boolean includeOrigin,
IntBag xPos,
IntBag yPos)
Gets all neighbors of a location that satisfy max( abs(xX) , abs(yY) ) <= dist.

void 
getNeighborsHamiltonianDistance(int x,
int y,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos)
Deprecated.

void 
getNeighborsHexagonalDistance(int x,
int y,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos)
Deprecated.

void 
getNeighborsMaxDistance(int x,
int y,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos)
Deprecated.

void 
getRadialLocations(int x,
int y,
double dist,
int mode,
boolean includeOrigin,
IntBag xPos,
IntBag yPos)
Gets all neighbors overlapping with a circular region centered at (X,Y) and with a radius of dist.

void 
getRadialLocations(int x,
int y,
double dist,
int mode,
boolean includeOrigin,
int measurementRule,
boolean closed,
IntBag xPos,
IntBag yPos)
Gets all neighbors overlapping with a circular region centered at (X,Y) and with a radius of dist.

void 
getVonNeumannLocations(int x,
int y,
int dist,
int mode,
boolean includeOrigin,
IntBag xPos,
IntBag yPos)
Gets all neighbors of a location that satisfy abs(xX) + abs(yY) <= dist.

int 
getWidth()
Returns the width of the field.

protected void 
removeOrigin(int x,
int y,
IntBag xPos,
IntBag yPos) 
protected void 
removeOriginToroidal(int x,
int y,
IntBag xPos,
IntBag yPos) 
int 
stx(int x)
Simple [and fast] toroidal x.

int 
sty(int y)
Simple [and fast] toroidal y.

boolean 
trb(int x,
int y)
Horizontal edge is on the bottom for triangle.

boolean 
trt(int x,
int y)
Horizontal edge is on the top for triangle.

int 
tx(int x)
Toroidal x.

int 
ty(int y)
Toroidal y.

int 
ulx(int x,
int y)
Hex upleft x.

int 
uly(int x,
int y)
Hex upleft y.

int 
upx(int x,
int y)
Hex up x.

int 
upy(int x,
int y)
Hex up y.

int 
urx(int x,
int y)
Hex upright x.

int 
ury(int x,
int y)
Hex upright y.

public final int getWidth()
Grid2D
public final int getHeight()
Grid2D
public java.util.Map buildMap(java.util.Map other)
Grid2D
public java.util.Map buildMap(int size)
Grid2D
public final int tx(int x)
Grid2D
public final int ty(int y)
Grid2D
public final int stx(int x)
Grid2D
public final int sty(int y)
Grid2D
public final int ulx(int x, int y)
Grid2D
public final int uly(int x, int y)
Grid2D
public final int urx(int x, int y)
Grid2D
public final int ury(int x, int y)
Grid2D
public final int dlx(int x, int y)
Grid2D
public final int dly(int x, int y)
Grid2D
public final int drx(int x, int y)
Grid2D
public final int dry(int x, int y)
Grid2D
public final int upx(int x, int y)
Grid2D
public final int upy(int x, int y)
Grid2D
public final int downx(int x, int y)
Grid2D
public final int downy(int x, int y)
Grid2D
public boolean trb(int x, int y)
Grid2D
public boolean trt(int x, int y)
Grid2D
public void getNeighborsMaxDistance(int x, int y, int dist, boolean toroidal, IntBag xPos, IntBag yPos)
Grid2D
This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so this function is deprecated: instead you should use the other version of this function which has more functionality. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
The origin  that is, the (x,y) point at the center of the neighborhood  is always included in the results.
This function is equivalent to: getNeighborsMaxDistance(x,y,dist,toroidal ? Grid2D.TOROIDAL : Grid2D.BOUNDED, true, xPos, yPos);
getNeighborsMaxDistance
in interface Grid2D
public void getMooreLocations(int x, int y, int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos)
Grid2D
This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin  that is, the (x,y) point at the center of the neighborhood  in the neighborhood results.
getMooreLocations
in interface Grid2D
public void getNeighborsHamiltonianDistance(int x, int y, int dist, boolean toroidal, IntBag xPos, IntBag yPos)
Grid2D
This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so this function is deprecated: instead you should use the other version of this function which has more functionality. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
The origin  that is, the (x,y) point at the center of the neighborhood  is always included in the results.
This function is equivalent to: getNeighborsHamiltonianDistance(x,y,dist,toroidal ? Grid2D.TOROIDAL : Grid2D.BOUNDED, true, xPos, yPos);
getNeighborsHamiltonianDistance
in interface Grid2D
public void getVonNeumannLocations(int x, int y, int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos)
Grid2D
This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin  that is, the (x,y) point at the center of the neighborhood  in the neighborhood results.
getVonNeumannLocations
in interface Grid2D
public void getNeighborsHexagonalDistance(int x, int y, int dist, boolean toroidal, IntBag xPos, IntBag yPos)
Grid2D
This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so this function is deprecated: instead you should use the other version of this function which has more functionality. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
The origin  that is, the (x,y) point at the center of the neighborhood  is always included in the results.
This function is equivalent to: getNeighborsHexagonalDistance(x,y,dist,toroidal ? Grid2D.TOROIDAL : Grid2D.BOUNDED, true, xPos, yPos);
getNeighborsHexagonalDistance
in interface Grid2D
public void getHexagonalLocations(int x, int y, int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos)
Grid2D
This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin  that is, the (x,y) point at the center of the neighborhood  in the neighborhood results.
getHexagonalLocations
in interface Grid2D
public void getRadialLocations(int x, int y, double dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos)
Grid2D
Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin  that is, the (x,y) point at the center of the neighborhood  in the neighborhood results.
getRadialLocations
in interface Grid2D
public void getRadialLocations(int x, int y, double dist, int mode, boolean includeOrigin, int measurementRule, boolean closed, IntBag xPos, IntBag yPos)
Grid2D
Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wraparound, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin  that is, the (x,y) point at the center of the neighborhood  in the neighborhood results.
getRadialLocations
in interface Grid2D
protected void checkBounds(Grid2D other)