private static Node replaceCurrent(Node parent, Node previous, Node current, Node replacement) { if (previous == null) { if (!(current == parent.FirstChild)) { Context.CodeBug(); } parent.replaceChild(current, replacement); } else if (previous.next == current) { // Check cachedPrev.next == current is necessary due to possible // tree mutations parent.replaceChildAfter(previous, replacement); } else { parent.replaceChild(current, replacement); } return(replacement); }
private static Node replaceCurrent (Node parent, Node previous, Node current, Node replacement) { if (previous == null) { if (!(current == parent.FirstChild)) Context.CodeBug (); parent.replaceChild (current, replacement); } else if (previous.next == current) { // Check cachedPrev.next == current is necessary due to possible // tree mutations parent.replaceChildAfter (previous, replacement); } else { parent.replaceChild (current, replacement); } return replacement; }