lrs
Class ANode<T>

java.lang.Object
  extended by lrs.ANode<T>
Direct Known Subclasses:
EmptyNode, NENode

abstract class ANode<T>
extends java.lang.Object

Represents the abstract list state. Has a concrete toString () method that uses anynomous inner classes to compute the String representation of the LRStruct owner.

Since:
8/25/05

Field Summary
private  IAlgo<T,java.lang.String,java.lang.Void> ToStringAlgo
          Uses anonymous visitor class to compute a String representation.
 
Constructor Summary
ANode()
           
 
Method Summary
(package private) abstract
<R,P> R
execute(LRStruct<T> owner, IAlgo<T,R,P> algo, P... inp)
          Executes a visitor algorithm and returns the output.
(package private) abstract  T getFirst(LRStruct<T> owner)
          Returns the first data object of the referencing LRStruct.
(package private) abstract  LRStruct<T> getRest(LRStruct<T> owner)
          Returns the tail LRStruct of the referencing LRStruct.
(package private) abstract  LRStruct<T> insertFront(T dat, LRStruct<T> owner)
          Inserts a data object at the front of the LRStruct owner.
(package private) abstract  T removeFront(LRStruct<T> owner)
          Removes and returns the first data object for the referencing LRStruct.
(package private) abstract  LRStruct<T> setFirst(T dat, LRStruct<T> owner)
          Sets a new first data object for the referencing LRStruct.
(package private) abstract  LRStruct<T> setRest(LRStruct<T> tail, LRStruct<T> owner)
          Sets a new tail for the referencing LRStruct.
(package private)  java.lang.String toString(LRStruct<T> owner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ToStringAlgo

private final IAlgo<T,java.lang.String,java.lang.Void> ToStringAlgo
Uses anonymous visitor class to compute a String representation.

Constructor Detail

ANode

ANode()
Method Detail

toString

java.lang.String toString(LRStruct<T> owner)

getRest

abstract LRStruct<T> getRest(LRStruct<T> owner)
Returns the tail LRStruct of the referencing LRStruct.

Parameters:
owner - the LRStruct referencing this ANode.
Returns:
the tail LRStruct of owner.

getFirst

abstract T getFirst(LRStruct<T> owner)
Returns the first data object of the referencing LRStruct.

Parameters:
owner - the LRStruct referencing this ANode.
Returns:
the tail LRStruct of owner.

setRest

abstract LRStruct<T> setRest(LRStruct<T> tail,
                             LRStruct<T> owner)
Sets a new tail for the referencing LRStruct.

Parameters:
tail - the new tail for the owner LRStruct.
owner - the LRS referencing this ANode.
Returns:
LRStruct owner

setFirst

abstract LRStruct<T> setFirst(T dat,
                              LRStruct<T> owner)
Sets a new first data object for the referencing LRStruct.

Parameters:
first - the new data object for this ANode.
owner - the LRS referencing this ANode.
Returns:
LRStruct owner

insertFront

abstract LRStruct<T> insertFront(T dat,
                                 LRStruct<T> owner)
Inserts a data object at the front of the LRStruct owner.

Parameters:
dat - the object to be inserted at the front.
owner - the LRS referencing this ANode.
Returns:
LRStruct owner

removeFront

abstract T removeFront(LRStruct<T> owner)
Removes and returns the first data object for the referencing LRStruct.

Parameters:
owner - the LRS referencing this ANode.
Returns:
the front data of the LRStruct owner.

execute

abstract <R,P> R execute(LRStruct<T> owner,
                         IAlgo<T,R,P> algo,
                         P... inp)
Executes a visitor algorithm and returns the output.

Parameters:
owner - the LRStruct referencing this ANode.
algo - the visitor algorithm to be executed.
inp - the inputs needed by the algorithm.