BIND 10 trac2218_2, updated. 9ec629f3465d8651ceaf5b766fc91598e26f7023 [2218] Add DomainTreeNode::getLargestInSubTree() method

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Sep 19 07:23:05 UTC 2012


The branch, trac2218_2 has been updated
       via  9ec629f3465d8651ceaf5b766fc91598e26f7023 (commit)
       via  d06e139eb2d03ef254ab8b2f3f56083addcfe756 (commit)
       via  b169803e955bf7c5647f4c67bd851b2a9a03630c (commit)
      from  d047c08a96270d4d757dc4c0bcd4dfece3bf586a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9ec629f3465d8651ceaf5b766fc91598e26f7023
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Sep 19 12:51:33 2012 +0530

    [2218] Add DomainTreeNode::getLargestInSubTree() method
    
    This is used to find the largest (covering) node under the origin's
    subtree in the NSEC3 tree.

commit d06e139eb2d03ef254ab8b2f3f56083addcfe756
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Sep 19 12:44:27 2012 +0530

    [2218] Remove DomainTree::getLargestNode()
    
    ... which was broken anyway.

commit b169803e955bf7c5647f4c67bd851b2a9a03630c
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Sep 19 12:42:13 2012 +0530

    [2218] Add DomainTreeNode::getSubTreeRoot()

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/memory/domaintree.h |   59 ++++++++++++++++++++---------------
 1 file changed, 34 insertions(+), 25 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index 339a905..c0b74eb 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -384,6 +384,13 @@ public:
         return ((flags_ & FLAG_SUBTREE_ROOT) != 0);
     }
 
+    /// \brief returns the root of its subtree
+    ///
+    /// This method takes a node and returns the root of its subtree.
+    ///
+    /// This method never throws an exception.
+    const DomainTreeNode<T>* getSubTreeRoot() const;
+
     /// \brief returns the parent of the root of its subtree
     ///
     /// This method takes a node and returns the parent of the root of
@@ -394,6 +401,14 @@ public:
     /// This method never throws an exception.
     const DomainTreeNode<T>* getUpperNode() const;
 
+    /// \brief returns the largest node of this node's subtree
+    ///
+    /// This method takes a node and returns the largest node in its
+    /// subtree.
+    ///
+    /// This method never throws an exception.
+    const DomainTreeNode<T>* getLargestInSubTree() const;
+
     /// \brief return the next node which is bigger than current node
     /// in the same subtree
     ///
@@ -544,7 +559,7 @@ DomainTreeNode<T>::~DomainTreeNode() {
 
 template <typename T>
 const DomainTreeNode<T>*
-DomainTreeNode<T>::getUpperNode() const {
+DomainTreeNode<T>::getSubTreeRoot() const {
     const DomainTreeNode<T>* current = this;
 
     // current would never be equal to NULL here (in a correct tree
@@ -553,7 +568,24 @@ DomainTreeNode<T>::getUpperNode() const {
         current = current->getParent();
     }
 
-    return (current->getParent());
+    return (current);
+}
+
+template <typename T>
+const DomainTreeNode<T>*
+DomainTreeNode<T>::getUpperNode() const {
+    return (getSubTreeRoot()->getParent());
+}
+
+template <typename T>
+const DomainTreeNode<T>*
+DomainTreeNode<T>::getLargestInSubTree() const {
+    const DomainTreeNode<T>* sroot = getSubTreeRoot();
+    while (sroot->getRight() != NULL) {
+        sroot = sroot->getRight();
+    }
+
+    return (sroot);
 }
 
 template <typename T>
@@ -1220,14 +1252,6 @@ public:
     }
     //@}
 
-    /// \brief return the largest node (right-most last node) in the
-    /// tree.
-    ///
-    /// \return A \c DomainTreeNode that is largest in the tree. If the
-    /// tree has no nodes, NULL will be returned.
-    const DomainTreeNode<T>*
-    getLargestNode() const;
-
     /// \brief return the next bigger node in DNSSEC order from a given node
     /// chain.
     ///
@@ -1724,21 +1748,6 @@ DomainTree<T>::previousNode(DomainTreeNodeChain<T>& node_path) const {
 }
 
 template <typename T>
-const DomainTreeNode<T>*
-DomainTree<T>::getLargestNode() const {
-    const DomainTreeNode<T>* node = root_.get();
-    if (node == NULL) {
-        return (NULL);
-    }
-
-    while (node->getRight() != NULL) {
-        node = node->getRight();
-    }
-
-    return (node);
-}
-
-template <typename T>
 typename DomainTree<T>::Result
 DomainTree<T>::insert(util::MemorySegment& mem_sgmt,
                       const isc::dns::Name& target_name,



More information about the bind10-changes mailing list