From: Stephan Bosch Date: Mon, 30 Sep 2019 08:30:25 +0000 (+0200) Subject: iputils.hh: NetmaskTree::TreeNode: Implement tree traversal methods. X-Git-Tag: auth-4.3.0-beta2~20^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fddcd1ccfcf8621acb478a6aedd1f08971460843;p=thirdparty%2Fpdns.git iputils.hh: NetmaskTree::TreeNode: Implement tree traversal methods. --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 9a66e13b84..ce938c7b43 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -761,6 +761,51 @@ private: return new_node; } + //left) + tnode = tnode->left.get(); + return tnode; + } + + //right) { + // descend right + tnode = tnode->right.get(); + // descend left as deep as possible and return next node + return tnode->traverse_l(); + } + + // ascend to parent + while (tnode->parent != nullptr) { + TreeNode *prev_child = tnode; + tnode = tnode->parent; + + // return this node, but only when we come from the left child branch + if (tnode->left && tnode->left.get() == prev_child) + return tnode; + } + return nullptr; + } + + //assigned) + tnode = tnode->traverse_lnr(); + return tnode; + } + unique_ptr left; unique_ptr right; TreeNode* parent;