Commit d6611821 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

clarified comments on successor() and null node detection


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac397@3618 e5f2f494-b856-4b98-b285-d166d9295462
parent 2f902e9e
......@@ -167,7 +167,8 @@ const RBNode<T>*
RBNode<T>::successor() const {
const RBNode<T>* current = this;
// if it has right node, the successor is the left-most node
// If it has right node, the successor is the left-most node of the right
// subtree.
if (right_ != NULL_NODE()) {
current = right_;
while (current->left_ != NULL_NODE()) {
......@@ -176,10 +177,11 @@ RBNode<T>::successor() const {
return (current);
}
// otherwise return the parent without left child or
// current node is not its right child
// Otherwise go up until we find the first left branch on our path to
// root. If found, the parent of the branch is the successor.
// Otherwise, we return the null node.
const RBNode<T>* s = current->parent_;
while (s != s->left_ && current == s->right_) {
while (s != NULL_NODE() && current == s->right_) {
current = s;
s = s->parent_;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment