From: Mukund Sivaraman Date: Mon, 26 Aug 2013 02:57:12 +0000 (+0530) Subject: [2750] Add getSibling() method X-Git-Tag: bind10-1.2.0beta1-release~193^2~4^2~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f0bb9294f71b325836f3c4fd8989b382627c19a;p=thirdparty%2Fkea.git [2750] Add getSibling() method --- diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h index 0d94243cf0..6822e2a49f 100644 --- a/src/lib/datasrc/memory/domaintree.h +++ b/src/lib/datasrc/memory/domaintree.h @@ -569,6 +569,22 @@ private: } } + /// \brief Access sibling node as bare pointer. + /// + /// A sibling node is defined as the parent's other child. It exists + /// at the same level as this node. + /// + /// \return the sibling node if one exists, NULL otherwise. + DomainTreeNode* getSibling() { + DomainTreeNode* parent = getParent(); + + if (parent->getLeft() == this) { + return (parent->getRight()); + } else { + return (parent->getLeft()); + } + } + /// \brief Access uncle node as bare pointer. /// /// An uncle node is defined as the parent node's sibling. It exists