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

## uchicago.src.sim.space
Class AbsMulti2DTorus

    java.lang.Object
      uchicago.src.sim.space.AbsMulti2DGrid
          uchicago.src.sim.space.AbsMulti2DTorus

All Implemented Interfaces:
  Discrete2DSpace, IMulti2DGrid, Torus

Direct Known Subclasses:
  AbsMulti2DHexagonalTorus, Multi2DTorus, OrderedMulti2DTorus

    public abstract class AbsMulti2DTorus

extends AbsMulti2DGrid
implements Torus

Base class for tori whose cells can hold more that one occupant. The actual object held in the grid cell is a Cell object.

Version:
  $Revision: 1.6 $ $Date: 2004/11/03 19:50:57 $

Field Summary

Fields inherited from class uchicago.src.sim.space.AbsMulti2DGrid
`matrix, roIter, roList, xSize, ySize`

Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace
`MOORE, VON_NEUMANN`

Constructor Summary
`AbsMulti2DTorus(int xSize, int ySize, boolean sparse)` Creates this AbsMulti2DGrid with the specified dimensions.

Method Summary
`void` | `clear(int x, int y)` Clears the contents the specified cell.
`Cell` | `getCellAt(int x, int y)` Gets the Cell object at the specified coordinates.
`int` | `getCellSizeAt(int x, int y)` Gets the size (number of occupants) of the cell at the specified location.
`java.util.Iterator` | `getIteratorAt(int x, int y)` Gets the iterator for the collection of objects at the specified coordinates.
`BaseMatrix` | `getMatrix()` Gets the matrix collection class that contains all the values
`java.util.ArrayList` | `getMooreNeighbors(int x, int y, boolean returnNulls)` Gets the Moore neighbors of the object(s) at x, y.
`java.util.ArrayList` | `getMooreNeighbors(int x, int y, int xExtent, int yExtent, boolean returnNulls)` Gets the extended Moore neighbors of the object(s) at x, y.
`java.util.ArrayList` | `getMooreNeighborsLoc(int x, int y, boolean returnNulls)` Gets the Moore neighbors of the object(s) at x, y.
`java.util.ArrayList` | `getMooreNeighborsLoc(int x, int y, int xExtent, int yExtent, boolean returnNulls)` Gets the extended Moore neighbors of the object(s) at x, y.
`java.lang.Object` | `getObjectAt(int x, int y)` Gets the Object at the specified coordinate.
`java.util.List` | `getObjectsAt(int x, int y)` Gets the List of objects at the specified coordinates.
`double` | `getValueAt(int x, int y)` Gets the value at the specified coordinate if appropriate.
`java.util.ArrayList` | `getVNNeighbors(int x, int y, boolean returnNulls)` Gets the von Neumann neighbors of the object(s) at x, y.
`java.util.ArrayList` | `getVNNeighbors(int x, int y, int xExtent, int yExtent, boolean returnNulls)` Gets the extended von Neumann neighbors of the objects(s) at x, y.
`java.util.ArrayList` | `getVNNeighborsLoc(int x, int y, boolean returnNulls)` Gets the von Neumann neighbors of the object(s) at x, y.
`java.util.ArrayList` | `getVNNeighborsLoc(int x, int y, int xExtent, int yExtent, boolean returnNulls)` Gets the extended von Neumann neighbors of the objects(s) at x, y.
`abstract void` | `putObjectAt(int x, int y, java.lang.Object object)` Puts the specified Object at the specified coordinate.
`void` | `putValueAt(int x, int y, double value)` Puts the specified value at the specified coordinate.
`void` | `removeObjectAt(int x, int y, java.lang.Object obj)` Removes the specified object from the specified location.
`void` | `trim()` Releases any superfluous memory.
`int` | `xnorm(int x)` Normalize the x value to the toroidal coordinates
`int` | `ynorm(int y)` Normalize the y value to the toroidal coordinates

Methods inherited from class uchicago.src.sim.space.AbsMulti2DGrid
`getSize, getSizeX, getSizeY, rangeCheck`

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

Constructor Detail

### AbsMulti2DTorus

    public AbsMulti2DTorus(int xSize,
                           int ySize,
                           boolean sparse)

  Creates this AbsMulti2DGrid with the specified dimensions. sparse specifies whether the grid will be sparsely filled or not. Specifying sparse can result in substantial memory savings.

  Parameters:
    `xSize` - the number of columns in the grid
    `ySize` - the number of rows in the grid
    `sparse` - whether the grid will be sparsely populated or not

Method Detail

### clear

    public void clear(int x,
                      int y)

  Clears the contents the specified cell.

  Overrides:
    `clear` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the cell to clear
    `y` - the y coordinate of the cell to clear

### getObjectsAt

    public java.util.List getObjectsAt(int x,
                                       int y)

  Gets the List of objects at the specified coordinates. An ordered torus will return the first object inserted at the beginning of the list and the last object inserted at the end of the list. The list order is undetermined for an unordered torus.

  Specified by:
    `getObjectsAt` in interface `IMulti2DGrid`
  Overrides:
    `getObjectsAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
  Returns:
    the list of objects at the specified location.If no objects are at the location the list will be empty (and unmodifable).

### getIteratorAt

    public java.util.Iterator getIteratorAt(int x,
                                            int y)

  Gets the iterator for the collection of objects at the specified coordinates. For an ordered torus the order of iteration will be first object inserted, first returned and so on. For an unordered torus, order is undefined.

  Specified by:
    `getIteratorAt` in interface `IMulti2DGrid`
  Overrides:
    `getIteratorAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
  Returns:
    an iterator for the objects at the specified location. If no objects are at the location, the iterator will be empty.

### getCellAt

    public Cell getCellAt(int x,
                          int y)

  Gets the Cell object at the specified coordinates.

  Specified by:
    `getCellAt` in interface `IMulti2DGrid`
  Overrides:
    `getCellAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate

### getVNNeighborsLoc

    public java.util.ArrayList getVNNeighborsLoc(int x,
                                                 int y,
                                                 boolean returnNulls)

  Gets the von Neumann neighbors of the object(s) at x, y. Objects are returned in west, east, north, south order. The returned ArrayList contains `ObjectLocation` objects that can be used to determined the exact location of the object returned. The coordinates in the ObjectLocation object will be normalized. The objects at x, y are not returned.

  If the neighboring objects contain their location information, `getVNNeighbors(...)` should be used as it is faster.

  Overrides:
    `getVNNeighborsLoc` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `returnNulls` - whether nulls (nothing at x,y) should be returned
  Returns:
    an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
  See Also:
    `ObjectLocation`

### getVNNeighborsLoc

    public java.util.ArrayList getVNNeighborsLoc(int x,
                                                 int y,
                                                 int xExtent,
                                                 int yExtent,
                                                 boolean returnNulls)

  Gets the extended von Neumann neighbors of the objects(s) at x, y. The extension in the x and y direction are specified by xExtent and yExtent. Objects are returned in west, east, north, south order. The most distant objects are returned first, that is, all the objects to the west starting with the most distant, then those to the east and so on. The returned ArrayList contains `ObjectLocation` objects that can be used to determined the exact location of the object returned. The coordinates in the ObjectLocation object will be normalized. The objects at x, y are not returned.

  If the neighboring objects contain their location information, `getVNNeighbors(...)` should be used as it is faster.

  Overrides:
    `getVNNeighborsLoc` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `xExtent` - the extension of the neighborhood in the x direction
    `yExtent` - the extension of the neighborhood in the y direction
    `returnNulls` - whether nulls should be returned
  Returns:
    an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
  See Also:
    `ObjectLocation`

### getMooreNeighborsLoc

    public java.util.ArrayList getMooreNeighborsLoc(int x,
                                                    int y,
                                                    boolean returnNulls)

  Gets the Moore neighbors of the object(s) at x, y. The returned ArrayList contains `ObjectLocation` objects that can be used to determined the exact location of the object returned. The coordinates in the ObjectLocation object will be normalized. Objects are returned by row starting with the "NW corner" and ending with the "SE corner."

  If the neighboring objects contain their location information, `getMooreNeighbors(...)` should be used as it is faster.

  Overrides:
    `getMooreNeighborsLoc` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `returnNulls` - should the returned Vector contain null objects
  Returns:
    an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
  See Also:
    `ObjectLocation`

### getMooreNeighborsLoc

    public java.util.ArrayList getMooreNeighborsLoc(int x,
                                                    int y,
                                                    int xExtent,
                                                    int yExtent,
                                                    boolean returnNulls)

  Gets the extended Moore neighbors of the object(s) at x, y. The extension in the x and y direction are specified by xExtent and yExtent. The returned ArrayList contains `ObjectLocation` objects that can be used to determined the exact location of the object returned. The coordinates in the ObjectLocation object will be normalized. The objects at x, y are not returned. Objects are returned by row starting with the "NW corner" and ending with the "SE corner."

  If the neighboring objects contain their location information, `getMooreNeighbors(...)` should be used as it is faster.

  Overrides:
    `getMooreNeighborsLoc` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `xExtent` - the extension of the neighborhood in the x direction
    `yExtent` - the extension of the neighborhood in the y direction
    `returnNulls` - should the returned ArrayList contain null objects
  Returns:
    an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
  See Also:
    `ObjectLocation`

### getVNNeighbors

    public java.util.ArrayList getVNNeighbors(int x,
                                              int y,
                                              boolean returnNulls)

  Gets the von Neumann neighbors of the object(s) at x, y. Objects are returned in west, east, north, south order. The objects at x, y are not returned.

  If the neighboring objects do not contain their location information, `getVNNeighborsLoc(...)` can be used, although it is slower.

  Overrides:
    `getVNNeighbors` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `returnNulls` - whether nulls (nothing at x,y) should be returned
  Returns:
    an ArrayList of objects (and possibly nulls).

### getVNNeighbors

    public java.util.ArrayList getVNNeighbors(int x,
                                              int y,
                                              int xExtent,
                                              int yExtent,
                                              boolean returnNulls)

  Gets the extended von Neumann neighbors of the objects(s) at x, y. The extension in the x and y direction are specified by xExtent and yExtent. Objects are returned in west, east, north, south order. The most distant objects are returned first, that is, all the objects to the west starting with the most distant, then those to the east and so on. The objects at x,y are not returned.

  If the neighboring objects do not contain their location information, `getVNNeighborsLoc(...)` can be used, although it is slower.

  Overrides:
    `getVNNeighbors` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `xExtent` - the extension of the neighborhood in the x direction
    `yExtent` - the extension of the neighborhood in the y direction
    `returnNulls` - whether nulls should be returned
  Returns:
    an ArrayList of objects (and possibly nulls).

### getMooreNeighbors

    public java.util.ArrayList getMooreNeighbors(int x,
                                                 int y,
                                                 boolean returnNulls)

  Gets the Moore neighbors of the object(s) at x, y. The objects at x, y are not returned. Objects are returned by row starting with the "NW corner" and ending with the "SE corner."

  If the neighboring objects do not contain their location information, `getMooreNeighborsLoc(...)` can be used although it is slower.

  Overrides:
    `getMooreNeighbors` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `returnNulls` - should the returned ArrayList contain null objects
  Returns:
    an ArrayList of objects (and possibly nulls) ordered by row starting with the "NW corner" and ending with the "SE corner."

### getMooreNeighbors

    public java.util.ArrayList getMooreNeighbors(int x,
                                                 int y,
                                                 int xExtent,
                                                 int yExtent,
                                                 boolean returnNulls)

  Gets the extended Moore neighbors of the object(s) at x, y. The objects at x, y are not returned. Objects are returned by row starting with the "NW corner" and ending with the "SE corner."

  If the neighboring objects do not contain their location information, `getMooreNeighborsLoc(...)` can be used although it is slower.

  Overrides:
    `getMooreNeighbors` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate of the object
    `y` - the y coordinate of the object
    `xExtent` - the extension of the neighborhood in the x direction
    `yExtent` - the extension of the neighborhood in the y direction
    `returnNulls` - should the returned ArrayList contain null objects
  Returns:
    an ArrayList of objects (and possibly nulls) ordered by row starting with the "NW corner" and ending with the "SE corner."
  See Also:
    `ObjectLocation`

### getCellSizeAt

    public int getCellSizeAt(int x,
                             int y)

  Gets the size (number of occupants) of the cell at the specified location.

  Specified by:
    `getCellSizeAt` in interface `IMulti2DGrid`
  Overrides:
    `getCellSizeAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate

### removeObjectAt

    public void removeObjectAt(int x,
                               int y,
                               java.lang.Object obj)

  Removes the specified object from the specified location.

  Specified by:
    `removeObjectAt` in interface `IMulti2DGrid`
  Overrides:
    `removeObjectAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `obj` - the object to remove

### getObjectAt

    public java.lang.Object getObjectAt(int x,
                                        int y)

  Gets the Object at the specified coordinate.

  Specified by:
    `getObjectAt` in interface `Discrete2DSpace`
  Overrides:
    `getObjectAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
  Returns:
    the Cell at x,y

### getValueAt

    public double getValueAt(int x,
                             int y)

  Gets the value at the specified coordinate if appropriate.

  Specified by:
    `getValueAt` in interface `Discrete2DSpace`
  Overrides:
    `getValueAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
  Returns:
    the value at x, y

### putObjectAt

    public abstract void putObjectAt(int x,
                                     int y,
                                     java.lang.Object object)

  Puts the specified Object at the specified coordinate.

  Specified by:
    `putObjectAt` in interface `Discrete2DSpace`
  Specified by:
    `putObjectAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `object` - the object to put

### putValueAt

    public void putValueAt(int x,
                           int y,
                           double value)

  Puts the specified value at the specified coordinate.

  Specified by:
    `putValueAt` in interface `Discrete2DSpace`
  Overrides:
    `putValueAt` in class `AbsMulti2DGrid`
  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `value` - the value to put at x,y

### getMatrix

    public BaseMatrix getMatrix()

  Gets the matrix collection class that contains all the values

  Specified by:
    `getMatrix` in interface `Discrete2DSpace`
  Overrides:
    `getMatrix` in class `AbsMulti2DGrid`

### trim

    public void trim()

  Releases any superfluous memory. This is only usefull when working with sparse grids.

  Overrides:
    `trim` in class `AbsMulti2DGrid`

### xnorm

    public int xnorm(int x)

  Normalize the x value to the toroidal coordinates

  Parameters:
    `x` - the value to normalize
  Returns:
    the normalized value

### ynorm

    public int ynorm(int y)

  Normalize the y value to the toroidal coordinates

  Parameters:
    `y` - the value to normalize
  Returns:
    the normalized value

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