Commit 3093d369 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[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.
parent a03aed77
......@@ -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<T>* 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 <typename T>
class RBTree : public boost::noncopyable {
......@@ -1762,8 +1758,9 @@ RBTree<T>::dumpTreeHelper(std::ostream& os, const RBNode<T>* node,
}
indent(os, depth);
os << node->getName().toText() << " ("
<< ((node->getColor() == RBNode<T>::BLACK) ? "black" : "red") << ")";
os << node->getLabels() << " ("
<< ((node->getColor() == RBNode<T>::BLACK) ? "black" : "red")
<< ")";
if (node->isEmpty()) {
os << " [invisible]";
}
......@@ -1775,10 +1772,10 @@ RBTree<T>::dumpTreeHelper(std::ostream& os, const RBNode<T>* node,
const RBNode<T>* 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);
......
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment