/** * removes edge between this and left; removes edge between newLeft and its parent; creates new * edge between this and newLeft */ public void linkLeft(BSTNode newLeft) { if (getLeft() != newLeft) { if (getLeft() != null) { // remove edge between this and left unlinkLeft(); } if (newLeft != null) { if (newLeft.getParent() != null) { // remove edge between newLeft and its parent newLeft.unlinkParent(); } // create new edge between this and newLeft newLeft.setParent(this); } setLeft(newLeft); } }
public void isolate() { setLeft(setRight(setParent(null))); }
/** removes edge between this and left */ public void unlinkLeft() { getLeft().setParent(null); setLeft(null); }