de.tubs.cs.sc.casim
Class Lattice1D

java.lang.Object
  |
  +--de.tubs.cs.sc.casim.Lattice
        |
        +--de.tubs.cs.sc.casim.CALattice
              |
              +--de.tubs.cs.sc.casim.Lattice1D
All Implemented Interfaces:
java.io.Serializable

public class Lattice1D
extends CALattice

represents a one dimensional Lattice of cells. All cells are arranged in one single row. The data structure is a one dimensional array of Cells

See Also:
Lattice, Cell, Serialized Form

Field Summary
protected  de.tubs.cs.sc.casim.Cell[] cells
           
 
Fields inherited from class de.tubs.cs.sc.casim.CALattice
neighborhoodIndexes
 
Fields inherited from class de.tubs.cs.sc.casim.Lattice
boundaryHandler, lx, ly, lz
 
Constructor Summary
Lattice1D(java.lang.Class state, de.tubs.cs.sc.casim.LatticeDefinition ldef)
          Constructor creates the one dimensional array of cells and 2 BoundaryHandler calls reset to initialize all cells
 
Method Summary
protected  void backup()
          calls backup for each cell
 int getDimension()
           
protected  de.tubs.cs.sc.casim.State getNeighborRelative(de.tubs.cs.sc.casim.Cell cell, int x, int y, int z)
          returns the relative neighbor of cell with given relative coordinates.
protected  de.tubs.cs.sc.casim.State[] getNeighborsArbitrary(de.tubs.cs.sc.casim.Cell cell)
          returns a previously defined arbitrary neighborhood.
protected  de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell)
          returns the Moore neighborhood with radius 1.
protected  de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell, int r)
          returns the Moore neighborhood with radius r.
protected  de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell)
          returns the von Neumann neighborhood with radius 1.
protected  de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell, int r)
          returns the von Neumann neighborhood with radius r.
protected  int getNrOfNeighbors()
           
 de.tubs.cs.sc.casim.State getOldState(int x, int y, int z)
          returns the old state at the given coordinates.
 de.tubs.cs.sc.casim.State getState(int x)
          returns the current state at the given coordinate.
 de.tubs.cs.sc.casim.State getState(int x, int y)
          returns the current state at given coordinates y must be 0 otherwise a RuntimeException is thrown
 de.tubs.cs.sc.casim.State getState(int x, int y, int z)
          returns the current state at given coordinates y and z must be 0 otherwise a RuntimeException is thrown
protected  void reset()
          reallocates all cells and calls again State.initialize for one cell
protected  void setIs(int i1)
          Set the position in the lattice for neighborhood accesses.
protected  void transition()
          Calls transition for each cells state
 
Methods inherited from class de.tubs.cs.sc.casim.CALattice
defineNeighborsArbitrary, getNeighbors, reversetransition
 
Methods inherited from class de.tubs.cs.sc.casim.Lattice
addBoundaryHandler, beginBlock, callAnalyze, callInitialize, endBlock, finish, getBoundaryHandler, getDefinition, getStateClass, getX, getY, getZ, setNeighborhood, waitForReadyForBackup, waitForReadyForTransition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cells

protected de.tubs.cs.sc.casim.Cell[] cells
Constructor Detail

Lattice1D

public Lattice1D(java.lang.Class state,
                 de.tubs.cs.sc.casim.LatticeDefinition ldef)
          throws CAException
Constructor creates the one dimensional array of cells and 2 BoundaryHandler calls reset to initialize all cells

Parameters:
state - the Java class of the State of the cells of the lattice
ldef - the LatticeDefinition with further lattice parameters
Method Detail

getDimension

public int getDimension()
Specified by:
getDimension in class Lattice
Returns:
the dimension of the lattice

reset

protected void reset()
              throws CAException
reallocates all cells and calls again State.initialize for one cell

Specified by:
reset in class Lattice
CAException

getState

public de.tubs.cs.sc.casim.State getState(int x)
returns the current state at the given coordinate. getState should be used in State's override initialize to init all states of the CA. The returned reference must be casted to a class derived from abstract class State.

Specified by:
getState in class Lattice
Returns:
the current state at position x

getState

public de.tubs.cs.sc.casim.State getState(int x,
                                          int y)
returns the current state at given coordinates y must be 0 otherwise a RuntimeException is thrown

Specified by:
getState in class Lattice
Parameters:
y - must be 0
Returns:
the current state at position x,y
See Also:
Lattice2D.getState(int)

getState

public de.tubs.cs.sc.casim.State getState(int x,
                                          int y,
                                          int z)
returns the current state at given coordinates y and z must be 0 otherwise a RuntimeException is thrown

Specified by:
getState in class Lattice
Parameters:
y - must be 0
z - must be 0
Returns:
the current state at position x,y,z
See Also:
Lattice3D.getState(int)

getOldState

public de.tubs.cs.sc.casim.State getOldState(int x,
                                             int y,
                                             int z)
returns the old state at the given coordinates. y and z are ignored for one dimensional lattices. getOldState is used by Cell to calculate the neighborhood set and by BoundaryHandlers.getOutSideState.

Specified by:
getOldState in class Lattice
Returns:
the old state at position x
See Also:
Cell.getNeighbors(), BoundaryHandler.getOutsideState(int)

backup

protected void backup()
calls backup for each cell

Specified by:
backup in class Lattice
See Also:
Lattice.backup()

transition

protected void transition()
Calls transition for each cells state

Specified by:
transition in class Lattice
See Also:
Lattice.transition()

getNrOfNeighbors

protected int getNrOfNeighbors()
Specified by:
getNrOfNeighbors in class CALattice
Returns:
the number of neighbors of every cell in the lattice

getNeighborsMoore

protected de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell,
                                                        int r)
returns the Moore neighborhood with radius r.

Specified by:
getNeighborsMoore in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsvonNeumann

protected de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell,
                                                             int r)
returns the von Neumann neighborhood with radius r.

Specified by:
getNeighborsvonNeumann in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsMoore

protected de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell)
returns the Moore neighborhood with radius 1.

Specified by:
getNeighborsMoore in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsvonNeumann

protected de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell)
returns the von Neumann neighborhood with radius 1.

Specified by:
getNeighborsvonNeumann in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborRelative

protected de.tubs.cs.sc.casim.State getNeighborRelative(de.tubs.cs.sc.casim.Cell cell,
                                                        int x,
                                                        int y,
                                                        int z)
returns the relative neighbor of cell with given relative coordinates.

Specified by:
getNeighborRelative in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsArbitrary

protected de.tubs.cs.sc.casim.State[] getNeighborsArbitrary(de.tubs.cs.sc.casim.Cell cell)
returns a previously defined arbitrary neighborhood.

Specified by:
getNeighborsArbitrary in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

setIs

protected void setIs(int i1)
Set the position in the lattice for neighborhood accesses. This is used for subclasses that implement transition directly, but need to access th eoriginal trnasition function at the borders.