gzz.impl
Class AbstractDim

gzz.Dim gzz.diff.DeltaDim gzz.impl.AbstractDim gzz.impl.SimpleDim gzz.impl.NormalDim ../../../Gzz_Backend.gen.html#impldims impldims_small
java.lang.Object
  |
  +--gzz.impl.AbstractDim
All Implemented Interfaces:
Dim
Direct Known Subclasses:
SimpleDim

public abstract class AbstractDim
extends java.lang.Object
implements Dim

Abstract implementation of Dim with standard implementations for most methods. Some of the basic routines are given here so that they may be optimized. The absolute core routines that every subclass must implement are the abstract routines s, connect and disconnect. There are also other routines which may be optimizable but they should be implemented as separate classes.

Note that some of the methods are defined using each other; to avoid infinite loops (a la java.awt.FontMetrics) you have to implement at least one s and one h.

See Also:
TestSimpleDim

Field Summary
protected  java.lang.String id
          The identifier.
static java.lang.String rcsid
           
protected  Space space
          The space this dimension is affiliated with.
 
Constructor Summary
AbstractDim(Space space)
          Deprecated. Must provide id to constructor.
AbstractDim(Space space, java.lang.String id)
           
 
Method Summary
 void canonicalizeCells()
           
abstract  void connect(Cell c, Cell d)
          Connect the two cells in this dimension, in order.
 void connect(Cell c, int dir, Cell d)
          Connect two cells in direction given.
abstract  void disconnect(Cell c, int dir)
          Disconnect the cell in the given direction.
 void excise(Cell c)
          Remove the given cell from this dimension.
 void exciseRange(Cell neg, Cell pos)
          Excise a whole range of cells from a rank.
 java.lang.String getId()
          Get the identifier of this dimension.
 Space getSpace()
          Get the space this dimension is affilated with.
 Cell h(Cell c)
           
 Cell h(Cell c, int dir)
           
 Cell h(Cell c, int dir, Obs o)
          Get headcell.
 void hop(Cell c, int steps)
          Hop the cell along this dimension.
 void insert(Cell c, int dir, Cell d)
          Insert a cell on a rank.
 void insertRank(Cell c, int dir, Cell d)
          Insert a whole rank inside another rank.
abstract  boolean isCircularHead(Cell c, Obs o)
          Whether the given cell is a headcell of a circular rank on this dimension.
 java.util.Iterator iterator(Cell c)
          Iterate starting from the given cell.
 Cell s(Cell c)
           
 Cell s(Cell c, int steps)
           
abstract  Cell s(Cell c, int steps, Obs o)
          Get another cell steps steps on the dimension from c.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gzz.Dim
getHeadcells, getNegsides
 

Field Detail

rcsid

public static final java.lang.String rcsid
See Also:
Constant Field Values

space

protected final Space space
The space this dimension is affiliated with.


id

protected final java.lang.String id
The identifier.

Constructor Detail

AbstractDim

public AbstractDim(Space space,
                   java.lang.String id)

AbstractDim

public AbstractDim(Space space)
Deprecated. Must provide id to constructor.

DEPRECATED.

Method Detail

getSpace

public final Space getSpace()
Description copied from interface: Dim
Get the space this dimension is affilated with.

Specified by:
getSpace in interface Dim

getId

public final java.lang.String getId()
Description copied from interface: Dim
Get the identifier of this dimension.

Specified by:
getId in interface Dim

s

public abstract Cell s(Cell c,
                       int steps,
                       Obs o)
Description copied from interface: Dim
Get another cell steps steps on the dimension from c.

Specified by:
s in interface Dim
Parameters:
c - The cell
steps - Number of steps, can be negative.

connect

public abstract void connect(Cell c,
                             Cell d)
                      throws gzz.errors.ZZAlreadyConnectedException
Description copied from interface: Dim
Connect the two cells in this dimension, in order. This method is not allowed to break existing connections.

Specified by:
connect in interface Dim
Throws:
gzz.errors.ZZAlreadyConnectedException - If one of the cells is already connected.

disconnect

public abstract void disconnect(Cell c,
                                int dir)
Description copied from interface: Dim
Disconnect the cell in the given direction. It is not an error to disconnect something that is not connected.

Specified by:
disconnect in interface Dim

connect

public final void connect(Cell c,
                          int dir,
                          Cell d)
                   throws gzz.errors.ZZAlreadyConnectedException
Connect two cells in direction given. This is trivially implemented by this class and cannot be overridden.

Specified by:
connect in interface Dim
gzz.errors.ZZAlreadyConnectedException

s

public Cell s(Cell c,
              int steps)
Specified by:
s in interface Dim

s

public Cell s(Cell c)
Specified by:
s in interface Dim

isCircularHead

public abstract boolean isCircularHead(Cell c,
                                       Obs o)
Description copied from interface: Dim
Whether the given cell is a headcell of a circular rank on this dimension.

Specified by:
isCircularHead in interface Dim

h

public Cell h(Cell c,
              int dir,
              Obs o)
Get headcell. This function must return a cell always, even with circular ranks. In case of a circular rank, picking a cell depends on dimension. Ted recommends that it be user-pickable, especially for normal (user-modifiable) dimensions.

Specified by:
h in interface Dim

h

public Cell h(Cell c,
              int dir)
Specified by:
h in interface Dim

h

public Cell h(Cell c)
Specified by:
h in interface Dim

insert

public void insert(Cell c,
                   int dir,
                   Cell d)
            throws gzz.errors.ZZAlreadyConnectedException
Description copied from interface: Dim
Insert a cell on a rank.

Specified by:
insert in interface Dim
Parameters:
c - The cell next to which to insert the cell
dir - The direction from c in which it should be inserted
d - The cell to be inserted.
gzz.errors.ZZAlreadyConnectedException

excise

public void excise(Cell c)
Remove the given cell from this dimension.

Specified by:
excise in interface Dim

hop

public void hop(Cell c,
                int steps)
Description copied from interface: Dim
Hop the cell along this dimension.

Specified by:
hop in interface Dim

insertRank

public void insertRank(Cell c,
                       int dir,
                       Cell d)
Description copied from interface: Dim
Insert a whole rank inside another rank.

Specified by:
insertRank in interface Dim
Parameters:
c - The cell the rank is to be inserted at.
d - The headcell of the rank to be inserted.

exciseRange

public void exciseRange(Cell neg,
                        Cell pos)
Description copied from interface: Dim
Excise a whole range of cells from a rank. Makes the excised range an independent, non-looping rank.

Specified by:
exciseRange in interface Dim
Parameters:
neg - The negmost cell in the range to be excised.
pos - The posmost cell in the range to be excised.

iterator

public java.util.Iterator iterator(Cell c)
Iterate starting from the given cell. The iterator stops when going back over to c on circular ranks, or at end of ranks for normal ranks. Start from the headcell to go over all cells on the rank once, independent of whether it is circular or not.

Specified by:
iterator in interface Dim

canonicalizeCells

public void canonicalizeCells()