Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sim.field.grid
Class AbstractGrid3D

    java.lang.Object
      sim.field.grid.AbstractGrid3D

All Implemented Interfaces:
  Grid3D, java.io.Serializable

Direct Known Subclasses:
  DoubleGrid3D, IntGrid3D, ObjectGrid3D

public abstract class AbstractGrid3D
extends java.lang.Object
implements Grid3D

A concrete implementation of the Grid3D methods; used by several subclasses. Note that you should avoid calling these methods from an object of type Grid3D; instead try to call them from something more concrete (AbstractGrid3D or SparseGrid3D). Otherwise they will not get inlined. For example,

       Grid3D foo = ... ;
       foo.tx(4);  // will not get inlined

       AbstractGrid3D bar = ...;
       bar.tx(4);  // WILL get inlined

See Also:
  Serialized Form

Field Summary
`protected int` | `height`
`protected int` | `length`
`protected int` | `width`

Constructor Summary
`AbstractGrid3D()`

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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### width

    protected int width

### height

    protected int height

### length

    protected int length

Constructor Detail

### AbstractGrid3D

    public AbstractGrid3D()

Method Detail

### getWidth

    public final int getWidth()

  Description copied from interface: `Grid3D`
  Get the width

  Specified by:
    `getWidth` in interface `Grid3D`

### getHeight

    public final int getHeight()

  Description copied from interface: `Grid3D`
  Get the height

  Specified by:
    `getHeight` in interface `Grid3D`

### getLength

    public final int getLength()

  Description copied from interface: `Grid3D`
  Get the length

  Specified by:
    `getLength` in interface `Grid3D`

### tx

    public final int tx(int x)

  Description copied from interface: `Grid3D`
  Toroidal x. Defined as: (x%width+width)%width

  Specified by:
    `tx` in interface `Grid3D`

### ty

    public final int ty(int y)

  Description copied from interface: `Grid3D`
  Toroidal y. Defined as: (y%height+height)%height

  Specified by:
    `ty` in interface `Grid3D`

### tz

    public final int tz(int z)

  Description copied from interface: `Grid3D`
  Toroidal z. Defined as: (z%length+length)%length

  Specified by:
    `tz` in interface `Grid3D`

### stx

    public final int stx(int x)

  Description copied from interface: `Grid3D`
  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.

  Specified by:
    `stx` in interface `Grid3D`

### sty

    public final int sty(int y)

  Description copied from interface: `Grid3D`
  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.

  Specified by:
    `sty` in interface `Grid3D`

### stz

    public final int stz(int z)

  Description copied from interface: `Grid3D`
  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.

  Specified by:
    `stz` in interface `Grid3D`

### getNeighborsMaxDistance

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

  Specified by:
    `getNeighborsMaxDistance` in interface `Grid3D`

### getNeighborsHamiltonianDistance

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

  Specified by:
    `getNeighborsHamiltonianDistance` in interface `Grid3D`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD