sim.field.grid
Class IntGrid2D

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

public class IntGrid2D
extends AbstractGrid2D

A wrapper for 2D arrays of ints.

This object expects that the 2D arrays are rectangular. You are encouraged to access the array directly, but fast-inlined methods are provided for you if you want something safer. 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.

See Also:
Serialized Form

Field Summary
 int[][] field
           
 
Fields inherited from class sim.field.grid.AbstractGrid2D
height, width
 
Constructor Summary
IntGrid2D(IntGrid2D values)
           
IntGrid2D(int xdim, int ydim)
           
IntGrid2D(int xdim, int ydim, int initialValue)
           
 
Method Summary
 IntGrid2D add(int withThisMuch)
           
 IntGrid2D add(IntGrid2D withThis)
           
 int get(int x, int y)
           
 void getNeighborsHamiltonianDistance(int x, int y, int dist, boolean toroidal, IntBag result, IntBag xPos, IntBag yPos)
           
 void getNeighborsHexagonalDistance(int x, int y, int dist, boolean toroidal, IntBag result, IntBag xPos, IntBag yPos)
           
 void getNeighborsMaxDistance(int x, int y, int dist, boolean toroidal, IntBag result, IntBag xPos, IntBag yPos)
           
 IntGrid2D lowerBound(int toNoLowerThanThisMuch)
           
 int max()
           
 double mean()
           
 int min()
           
 IntGrid2D multiply(int byThisMuch)
           
 IntGrid2D multiply(IntGrid2D withThis)
           
 void set(int x, int y, int val)
           
 IntGrid2D setTo(int thisMuch)
           
 IntGrid2D setTo(IntGrid2D values)
           
 IntGrid2D upperBound(int toNoMoreThanThisMuch)
           
 
Methods inherited from class sim.field.grid.AbstractGrid2D
dlx, dly, downx, downy, drx, dry, getHeight, getNeighborsHamiltonianDistance, getNeighborsHexagonalDistance, getNeighborsMaxDistance, getWidth, stx, sty, 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 int[][] field
Constructor Detail

IntGrid2D

public IntGrid2D(int xdim,
                 int ydim)

IntGrid2D

public IntGrid2D(int xdim,
                 int ydim,
                 int initialValue)

IntGrid2D

public IntGrid2D(IntGrid2D values)
Method Detail

set

public final void set(int x,
                      int y,
                      int val)

get

public final int get(int x,
                     int y)

setTo

public final IntGrid2D setTo(int thisMuch)

setTo

public final IntGrid2D setTo(IntGrid2D values)

max

public final int max()

min

public final int min()

mean

public final double mean()

upperBound

public final IntGrid2D upperBound(int toNoMoreThanThisMuch)

lowerBound

public final IntGrid2D lowerBound(int toNoLowerThanThisMuch)

add

public final IntGrid2D add(int withThisMuch)

add

public final IntGrid2D add(IntGrid2D withThis)

multiply

public final IntGrid2D multiply(int byThisMuch)

multiply

public final IntGrid2D multiply(IntGrid2D withThis)

getNeighborsMaxDistance

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

getNeighborsHamiltonianDistance

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

getNeighborsHexagonalDistance

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