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 OrderedMulti2DHexagonalTorus

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

All Implemented Interfaces:
  Discrete2DSpace, IMulti2DGrid, Torus

    public class OrderedMulti2DHexagonalTorus

extends AbsMulti2DHexagonalTorus

A torus that can hold more than one object in its hexagonal cells. The cells themselves store their occupants in order of insertion, The list of objects in a cell contains the first object inserted at the beginning of the list and the last object inserted at the end. The object returned by getObject is a `OrderedCell`.

The hexagonal cells are referenced by x, y coordinates as follows:

           _
       _ / 1 \ _
     / 0 \ _ / 2 \
     \ _ / 4 \ _ /
     / 3 \ _ / 5 \
     \ _ / 7 \ _ /
     / 6 \ _ / 8 \
     \ _ /   \ _ /

Here we have a 3 x 3 hexagonal grid. The first row of cells is 0, 1, 2 such that 0,0 refers to cell 0, and 0,2 refers to cell 2. The next row of cells is 3, 4, 5, so 1,0 refers to cell 3 and so on. The last row of cells is 6, 7, and 8, so 2, 0 refers to cell 6. The ring of neighbors with radius one that surrounds cell 4 is composed of 1, 2, 5, 7, 3, and 0. The grid wraps as a toriod such that cell -1, 0 refers to cell 2 and cell 0, -1 is cell 6.

Version:
  $Revision: 1.4 $ $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
`OrderedMulti2DHexagonalTorus(int xSize, int ySize, boolean sparse)` Creates this OrderedMulti2DHexagonal Torus with the specified dimensions.

Method Summary
`int` | `getIndexOf(int x, int y, java.lang.Object obj)` Gets the index of the specified object at the specified location.
`java.lang.Object` | `getObjectAt(int x, int y, int index)` Gets the object at the specified location and index.
`void` | `putObjectAt(int x, int y, int index, java.lang.Object object)` Puts the specified Object into the cell at the specified coordinates and index.
`void` | `putObjectAt(int x, int y, java.lang.Object object)` Puts the specified Object into the cell at the specified coordinates.
`java.lang.Object` | `removeObjectAt(int x, int y, int index)` Removes the object at the specified index at the specified location from the grid.

Methods inherited from class uchicago.src.sim.space.AbsMulti2DHexagonalTorus
`getMooreNeighbors, getMooreNeighbors, getMooreNeighborsLoc, getMooreNeighborsLoc, getNeighbors, getNeighbors, getNeighborsLoc, getNeighborsLoc, getVNNeighbors, getVNNeighbors, getVNNeighborsLoc, getVNNeighborsLoc`

Methods inherited from class uchicago.src.sim.space.AbsMulti2DTorus
`clear, getCellAt, getCellSizeAt, getIteratorAt, getMatrix, getObjectAt, getObjectsAt, getValueAt, putValueAt, removeObjectAt, trim, xnorm, ynorm`

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

### OrderedMulti2DHexagonalTorus

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

  Creates this OrderedMulti2DHexagonal Torus with the specified dimensions. sparse specifies whether the torus will be sparsely filled or not.

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

Method Detail

### putObjectAt

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

  Puts the specified Object into the cell at the specified coordinates. The contents of the cell are ordered such that the first object inserted will be the first out and the last in the last out.

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

### putObjectAt

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

  Puts the specified Object into the cell at the specified coordinates and index. The contents of the cell are ordered such that the first object inserted will be the first out and the last in the last out. The index parameter can be used to specify where to insert the this object relative to the other objects at this location. The object at that location will be shifted to the right (i.e. have 1 added to index).

  Note this will throw an exception if the index is invalid.

  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `index` - where to insert the specified object relative to the other objects at this location
    `object` - the object to put

### getObjectAt

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

  Gets the object at the specified location and index. This will return null if there are no objects at the specified location and if the index is out of range (i.e. no object at that index).

  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `index` - the position of the object to get relative to the other objects in this list.

### getIndexOf

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

  Gets the index of the specified object at the specified location.

  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `obj` - the object to get the index for
  Returns:
    the index of the object if found at the specified location. If the object is not found for whatever reason, returns -1.

### removeObjectAt

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

  Removes the object at the specified index at the specified location from the grid.

  Parameters:
    `x` - the x coordinate
    `y` - the y coordinate
    `index` - the index of the object to remove
  Returns:
    the removed object or null

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