From: JINMEI Tatuya Date: Tue, 24 Jul 2012 00:53:42 +0000 (-0700) Subject: [2091b] cleanup: use getLabels() instead of name in dumpTree. X-Git-Tag: trac2351_base~158^2~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3093d3696dd1b882abe4fb5200903f4b4e97b2fb;p=thirdparty%2Fkea.git [2091b] cleanup: use getLabels() instead of name in dumpTree. It should be more accurate notation. Also, we should eventually get rid of getName() (we can't right now as it's used in node path). This change is one step toward that goal. Also made some editorial/docuementation cleanups. --- diff --git a/src/lib/datasrc/rbtree.h b/src/lib/datasrc/rbtree.h index c0ad87e730..b57c6479ff 100644 --- a/src/lib/datasrc/rbtree.h +++ b/src/lib/datasrc/rbtree.h @@ -123,7 +123,7 @@ private: /// /// \param mem_sgmt The \c MemorySegment that allocated memory for /// \c rbnode. - /// \param ztable A non NULL pointer to a valid \c RBNode object + /// \param rbnode A non NULL pointer to a valid \c RBNode object /// that was originally created by the \c create() method (the behavior /// is undefined if this condition isn't met). static void destroy(util::MemorySegment& mem_sgmt, RBNode* rbnode) { @@ -138,14 +138,10 @@ private: } /// TBD - const void* getLabelsData() const { - return (this + 1); - } + const void* getLabelsData() const { return (this + 1); } /// TBD - void* getLabelsData() { - return (this + 1); - } + void* getLabelsData() { return (this + 1); } public: /// \brief Alias for shared pointer to the data. @@ -752,6 +748,8 @@ private: * * the tree will look like: * \verbatim + . + | b / \ a d.e.f @@ -768,8 +766,6 @@ private: \endverbatim * \todo * - add remove interface - * - add iterator to iterate over the whole \c RBTree. This may be necessary, - * for example, to support AXFR. */ template class RBTree : public boost::noncopyable { @@ -1762,8 +1758,9 @@ RBTree::dumpTreeHelper(std::ostream& os, const RBNode* node, } indent(os, depth); - os << node->getName().toText() << " (" - << ((node->getColor() == RBNode::BLACK) ? "black" : "red") << ")"; + os << node->getLabels() << " (" + << ((node->getColor() == RBNode::BLACK) ? "black" : "red") + << ")"; if (node->isEmpty()) { os << " [invisible]"; } @@ -1775,10 +1772,10 @@ RBTree::dumpTreeHelper(std::ostream& os, const RBNode* node, const RBNode* down = node->getDown(); if (down != NULLNODE) { indent(os, depth + 1); - os << "begin down from " << node->getName().toText() << "\n"; + os << "begin down from " << node->getLabels() << "\n"; dumpTreeHelper(os, down, depth + 1); indent(os, depth + 1); - os << "end down from " << node->getName().toText() << "\n"; + os << "end down from " << node->getLabels() << "\n"; } dumpTreeHelper(os, node->getLeft(), depth + 1); dumpTreeHelper(os, node->getRight(), depth + 1); diff --git a/src/lib/datasrc/tests/rbtree_unittest.cc b/src/lib/datasrc/tests/rbtree_unittest.cc index ae235873cd..f45e08e1ab 100644 --- a/src/lib/datasrc/tests/rbtree_unittest.cc +++ b/src/lib/datasrc/tests/rbtree_unittest.cc @@ -769,45 +769,45 @@ TEST_F(RBTreeTest, dumpTree) { str2 << "tree has 15 node(s)\n" ". (black) [invisible] [subtreeroot]\n" " begin down from .\n" - " b. (black) [subtreeroot]\n" - " a. (black)\n" + " b (black) [subtreeroot]\n" + " a (black)\n" " NULL\n" " NULL\n" - " d.e.f. (black) [invisible]\n" - " begin down from d.e.f.\n" - " w.y. (black) [invisible] [subtreeroot]\n" - " begin down from w.y.\n" - " p. (black) [subtreeroot]\n" - " o. (red)\n" + " d.e.f (black) [invisible]\n" + " begin down from d.e.f\n" + " w.y (black) [invisible] [subtreeroot]\n" + " begin down from w.y\n" + " p (black) [subtreeroot]\n" + " o (red)\n" " NULL\n" " NULL\n" - " q. (red)\n" + " q (red)\n" " NULL\n" " NULL\n" - " end down from w.y.\n" - " x. (red)\n" + " end down from w.y\n" + " x (red)\n" " NULL\n" " NULL\n" - " z. (red)\n" - " begin down from z.\n" - " j. (black) [subtreeroot]\n" + " z (red)\n" + " begin down from z\n" + " j (black) [subtreeroot]\n" " NULL\n" " NULL\n" - " end down from z.\n" + " end down from z\n" " NULL\n" " NULL\n" - " end down from d.e.f.\n" - " c. (red)\n" + " end down from d.e.f\n" + " c (red)\n" " NULL\n" " NULL\n" - " g.h. (red)\n" - " begin down from g.h.\n" - " i. (black) [subtreeroot]\n" + " g.h (red)\n" + " begin down from g.h\n" + " i (black) [subtreeroot]\n" " NULL\n" - " k. (red)\n" + " k (red)\n" " NULL\n" " NULL\n" - " end down from g.h.\n" + " end down from g.h\n" " NULL\n" " NULL\n" " end down from .\n"