/** * Public interface for generic LRStruct. */ public class LRStruct { private ANode _head; public LRStruct() { _head = new EmptyNode(); } public String toString() { return _head.toString(this); } public final LRStruct insertFront(E dat) { return _head.insertFront(dat, this); } public final E removeFront() { return _head.removeFront(this); } public final E getFirst() { return _head.getFirst (this); } public final LRStruct setFirst(EE dat) { return _head.setFirst (dat, this); } public final LRStruct getRest() { return _head.getRest(this); } public final LRStruct setRest(LRStruct tail) { return _head.setRest(tail, this); } public final R execute(IAlgo algo, P ... inp) { return _head.execute(this, algo, inp); } /* Package access only: */ LRStruct(ANode node) { _head = node; } final LRStruct setHead (ANode head) { _head = head; return this; } final ANode getHead () { return _head; } } //// Visitor Interface public interface IAlgo { public abstract R emptyCase(LRStruct host, P... inp); public abstract R nonEmptyCase(LRStruct host, P... inp); }