]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2750] Add getSibling() method
authorMukund Sivaraman <muks@isc.org>
Mon, 26 Aug 2013 02:57:12 +0000 (08:27 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 26 Aug 2013 02:57:12 +0000 (08:27 +0530)
src/lib/datasrc/memory/domaintree.h

index 0d94243cf00994ff61efda01ec3b473be39281e1..6822e2a49f59759da7c0d4c56cf3874f212f5e31 100644 (file)
@@ -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<T>* getSibling() {
+        DomainTreeNode<T>* 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