Same fringe: Difference between revisions

Content added Content deleted
(→‎{{header|Scheme}}: bug -- reorder avoids (car '()) when trees differ only in length)
(Updated D entry)
Line 597: Line 597:
private Stack!BT stack;
private Stack!BT stack;


pure nothrow invariant() {
pure nothrow invariant {
assert(stack.empty || isLeaf(stack.head));
assert(stack.empty || isLeaf(stack.head));
}
}
Line 605: Line 605:
stack.push(t);
stack.push(t);
if (!isLeaf(t)) {
if (!isLeaf(t)) {
// Here invariant() doesn't hold.
// Here the invariant doesn't hold.
// invariant() isn't called for private methods.
// invariant isn't called for private methods.
nextLeaf();
nextLeaf;
}
}
}
}