Browse Source

[2218] Add DomainTreeNode::getLargestInSubTree() method

This is used to find the largest (covering) node under the origin's
subtree in the NSEC3 tree.
Mukund Sivaraman 12 years ago
parent
commit
9ec629f346
1 changed files with 19 additions and 0 deletions
  1. 19 0
      src/lib/datasrc/memory/domaintree.h

+ 19 - 0
src/lib/datasrc/memory/domaintree.h

@@ -401,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
     ///
@@ -570,6 +578,17 @@ DomainTreeNode<T>::getUpperNode() const {
 }
 
 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>
 isc::dns::LabelSequence
 DomainTreeNode<T>::getAbsoluteLabels(
     uint8_t buf[isc::dns::LabelSequence::MAX_SERIALIZED_LENGTH]) const