package lrs.visitor; import lrs.*; /** * Makes the host share the same head node with the input list. * The input list does not change. * @author DXN * @since 03/25/05 */ public class Share implements IAlgo { public final static Share Singleton = new Share (); private Share() { } /** * @param other [0] a LRStruct; * @return null */ public Object emptyCase(LRStruct host, Object... other) { return assign(host, (LRStruct)other[0]); } /** * @param other [0] a LRStruct; * @return null */ public Object nonEmptyCase(LRStruct host, Object... other) { return assign(host, (LRStruct)other[0]); } private Object assign (LRStruct lhs, LRStruct rhs) { lhs.insertFront(null); lhs.setRest(rhs); lhs.removeFront(); return null; } }