package clist; /** * Circular doubly-linked list implemented via the state pattern. * Framework with hooks to execute algorithms as visitors. * The notion of setting the "tail" of circular list does not make sense. Thus * CLList has no setTail method. * @author D. X. Nguyen * @since 10/24/00 */ public class CLList { /** @SBGen Variable (,,,64) */ private ANode _clockwiseHead; /** @SBGen Variable (,,,64) */ private ANode _counterwiseHead; public CLList() { _clockwiseHead = EmptyNode.Singleton; _counterwiseHead = EmptyNode.Singleton; } final public Object getClockwiseDat() { return _clockwiseHead.getDat (this); } final public Object getCounterwiseDat() { return _counterwiseHead.getDat (this); } final public CLList setClockwiseDat (Object dat) { return _clockwiseHead.setDat (dat, this); } final public CLList setCounterwiseDat (Object dat) { return _counterwiseHead.setDat (dat, this); } /** * @param dat */ final public CLList insertClockwise(Object dat) { return _clockwiseHead.insertClockwise (dat, this); } final public CLList insertCounterwise(Object dat) { return _counterwiseHead.insertCounterwise (dat, this); } final public Object remClockwise() { return _clockwiseHead.remClockwise (this); } final public Object remCounterwise() { return _counterwiseHead.remCounterwise (this); } final public CLList getClockwiseTail() { return _clockwiseHead.getClockwiseTail (this); } final public CLList getCounterwiseTail() { return _counterwiseHead.getCounterwiseTail (this); } final public Object execClockwise (ICLVisitor algo, CLList start, Object input) { return _clockwiseHead.execute (algo, start, input, this); } final public Object execCounterwise (ICLVisitor algo, CLList start, Object input) { return _counterwiseHead.execute (algo, start, input, this); } /** * When this CLList is brought into existence, all the wiring have been done right! * This is of vital importance! * @param clockwiseHead * @param counterwiseHead */ CLList(ANode counterwiseHead, ANode clockwiseHead) { _clockwiseHead = clockwiseHead; _clockwiseHead.setCounterwiseOwner (this); _counterwiseHead = counterwiseHead; _counterwiseHead.setClockwiseOwner (this); } /** * Makes node the clockwise node of owner and owner the counterClockwise owner of node. * Proper wiring is of vital importance. And it is done here in one place. * @param node */ final void setClockwiseHead(ANode node) { _clockwiseHead = node; _clockwiseHead.setCounterwiseOwner (this); } /** * Makes node the counter-clockwise node of owner and owner the clockwise owner of node. * Proper wiring is of vital importance. And it is done here in one place. * @param node */ final void setCounterwiseHead(ANode node) { _counterwiseHead = node; _counterwiseHead.setClockwiseOwner (this); } final ANode getClockwiseHead() { return _clockwiseHead; } final ANode getCounterwiseHead() { return _counterwiseHead; } }