sim.field.grid
Class ObjectGrid2D

java.lang.Object
  extended bysim.field.grid.AbstractGrid2D
      extended bysim.field.grid.ObjectGrid2D
All Implemented Interfaces:
Grid2D, java.io.Serializable

public class ObjectGrid2D
extends AbstractGrid2D

A wrapper for 2D arrays of Objects.

This object expects that the 2D arrays are rectangular. You are encouraged to access the array directly. The object implements all of the Grid2D interface. See Grid2D for rules on how to properly implement toroidal or hexagonal grids.

The width and height of the object are provided to avoid having to say field[x].length, etc.

If you need arbitrary numbers of Objects to be able to occupy the same location in the grid, or if you have very few Objects and a very large grid, you should probably use SparseGrid3D instead.

See Also:
Serialized Form

Field Summary
 java.lang.Object[][] field
           
 
Fields inherited from class sim.field.grid.AbstractGrid2D
height, width
 
Constructor Summary
ObjectGrid2D(int xdim, int ydim)
           
ObjectGrid2D(int xdim, int ydim, java.lang.Object initialValue)
           
ObjectGrid2D(ObjectGrid2D values)
           
 
Method Summary
 java.lang.Object get(int x, int y)
           
 void getNeighborsHamiltonianDistance(int x, int y, int dist, boolean toroidal, Bag result, IntBag xPos, IntBag yPos)
           
 void getNeighborsHexagonalDistance(int x, int y, int dist, boolean toroidal, Bag result, IntBag xPos, IntBag yPos)
           
 void getNeighborsMaxDistance(int x, int y, int dist, boolean toroidal, Bag result, IntBag xPos, IntBag yPos)
           
 void set(int x, int y, java.lang.Object val)
           
 ObjectGrid2D setTo(java.lang.Object thisObj)
           
 ObjectGrid2D setTo(ObjectGrid2D values)
           
 
Methods inherited from class sim.field.grid.AbstractGrid2D
dlx, dly, downx, downy, drx, dry, getHeight, getNeighborsHamiltonianDistance, getNeighborsHexagonalDistance, getNeighborsMaxDistance, getWidth, stx, sty, trb, trt, tx, ty, ulx, uly, upx, upy, urx, ury
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

field

public java.lang.Object[][] field
Constructor Detail

ObjectGrid2D

public ObjectGrid2D(int xdim,
                    int ydim)

ObjectGrid2D

public ObjectGrid2D(int xdim,
                    int ydim,
                    java.lang.Object initialValue)

ObjectGrid2D

public ObjectGrid2D(ObjectGrid2D values)
Method Detail

set

public final void set(int x,
                      int y,
                      java.lang.Object val)

get

public final java.lang.Object get(int x,
                                  int y)

setTo

public final ObjectGrid2D setTo(java.lang.Object thisObj)

setTo

public final ObjectGrid2D setTo(ObjectGrid2D values)

getNeighborsMaxDistance

public final void getNeighborsMaxDistance(int x,
                                          int y,
                                          int dist,
                                          boolean toroidal,
                                          Bag result,
                                          IntBag xPos,
                                          IntBag yPos)

getNeighborsHamiltonianDistance

public final void getNeighborsHamiltonianDistance(int x,
                                                  int y,
                                                  int dist,
                                                  boolean toroidal,
                                                  Bag result,
                                                  IntBag xPos,
                                                  IntBag yPos)

getNeighborsHexagonalDistance

public final void getNeighborsHexagonalDistance(int x,
                                                int y,
                                                int dist,
                                                boolean toroidal,
                                                Bag result,
                                                IntBag xPos,
                                                IntBag yPos)