sim.field.grid
Interface Grid3D
- All Superinterfaces:
- java.io.Serializable
- All Known Implementing Classes:
- AbstractGrid3D
- public interface Grid3D
- extends java.io.Serializable
Method Summary |
int |
getHeight()
Get the height |
int |
getLength()
Get the length |
void |
getNeighborsHamiltonianDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
|
void |
getNeighborsMaxDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
|
int |
getWidth()
Get the width |
int |
stx(int x)
Simple [and fast] toroidal x. |
int |
sty(int y)
Simple [and fast] toroidal y. |
int |
stz(int z)
Simple [and fast] toroidal z. |
int |
tx(int x)
Toroidal x. |
int |
ty(int y)
Toroidal y. |
int |
tz(int z)
Toroidal z. |
getWidth
public int getWidth()
- Get the width
getHeight
public int getHeight()
- Get the height
getLength
public int getLength()
- Get the length
tx
public int tx(int x)
- Toroidal x. The following definition:
final int length = this.length;
if (z >= 0) return (z % length);
final int length2 = (z % length) + length;
if (length2 < length) return length2;
return 0;
... produces the correct code and is 27 bytes, so it's likely to be inlined in Hotspot for 1.4.1.
ty
public int ty(int y)
- Toroidal y. The following definition:
final int length = this.length;
if (z >= 0) return (z % length);
final int length2 = (z % length) + length;
if (length2 < length) return length2;
return 0;
... produces the correct code and is 27 bytes, so it's likely to be inlined in Hotspot for 1.4.1.
tz
public int tz(int z)
- Toroidal z. The following definition:
final int length = this.length;
if (z >= 0) return (z % length);
final int length2 = (z % length) + length;
if (length2 < length) return length2;
return 0;
... produces the correct code and is 27 bytes, so it's likely to be inlined in Hotspot for 1.4.1.
stx
public int stx(int x)
- Simple [and fast] toroidal x. Use this if the values you'd pass in never stray
beyond (-width ... width * 2) not inclusive. It's a bit faster than the full
toroidal computation as it uses if statements rather than two modulos.
The following definition:
{ int width = this.width; if (x >= 0) { if (x < width) return x; return x - width; } return x + width; }
...produces the shortest code (24 bytes) and is inlined in Hotspot for 1.4.1. However
in most cases removing the int width = this.width; is likely to be a little faster if most
objects are usually within the toroidal region.
sty
public int sty(int y)
- Simple [and fast] toroidal y. Use this if the values you'd pass in never stray
beyond (-height ... height * 2) not inclusive. It's a bit faster than the full
toroidal computation as it uses if statements rather than two modulos.
The following definition:
{ int height = this.height; if (y >= 0) { if (y < height) return y ; return y - height; } return y + height; }
...produces the shortest code (24 bytes) and is inlined in Hotspot for 1.4.1. However
in most cases removing the int height = this.height; is likely to be a little faster if most
objects are usually within the toroidal region.
stz
public int stz(int z)
- Simple [and fast] toroidal z. Use this if the values you'd pass in never stray
beyond (-length ... length * 2) not inclusive. It's a bit faster than the full
toroidal computation as it uses if statements rather than two modulos.
The following definition:
{ int length = this.length; if (z >= 0) { if (z < length) return z ; return z - length; } return z + length; }
...produces the shortest code (24 bytes) and is inlined in Hotspot for 1.4.1. However
in most cases removing the int length = this.length; is likely to be a little faster if most
objects are usually within the toroidal region.
getNeighborsMaxDistance
public void getNeighborsMaxDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
getNeighborsHamiltonianDistance
public void getNeighborsHamiltonianDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)