package brs.visitor; import brs.*; import ordering.*; /** * Removes the root of the host's parent. Called by the left sibling to help * delete * the parent's root, so don't ask for the sibling to help! * @author Dung X. Nguyen */ public class RightDelDontAsk implements IVisitor { private BiTree _hostParent; private IVisitor _deleter; public RightDelDontAsk (BiTree parent, IVisitor del) { _hostParent = parent; _deleter = del; } /** * Asks the _hostParent to remove its root. * @param host the right subtree of _hostParent. * @param input not used. * @return */ public Object emptyCase(BiTree host, Object input) { _hostParent.remRoot (); return null; } /** * Finds the minimum value in the host. * Asks the _hostParent to set its root to this minimum value, and removes * this minimum value from the host. * @param host the right subtree of _hostParent. * @param input not used. * @return */ public Object nonEmptyCase(BiTree host, Object input) { BiTree minTree = (BiTree)host.execute (MinTreeFinder.Singleton, null); Object min = minTree.getRootDat(); _hostParent.setRootDat(min); minTree.execute (_deleter, min); return null; } }