Fix up indenting and empty children in to_string for node
This commit is contained in:
@@ -104,7 +104,7 @@ word_t alloc_node(Node n)
|
|||||||
void indent_depth(int depth, std::stringstream &ss)
|
void indent_depth(int depth, std::stringstream &ss)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < depth; ++i)
|
for (int i = 0; i < depth; ++i)
|
||||||
ss << "\t";
|
ss << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_string(Node n, int depth = 1)
|
std::string to_string(Node n, int depth = 1)
|
||||||
@@ -113,13 +113,13 @@ std::string to_string(Node n, int depth = 1)
|
|||||||
ss << "(" << to_string(n.value) << "\n";
|
ss << "(" << to_string(n.value) << "\n";
|
||||||
indent_depth(depth, ss);
|
indent_depth(depth, ss);
|
||||||
if (n.left == -1)
|
if (n.left == -1)
|
||||||
ss << "()";
|
ss << "NIL";
|
||||||
else
|
else
|
||||||
ss << to_string(nodes[n.left], depth + 1);
|
ss << to_string(nodes[n.left], depth + 1);
|
||||||
ss << "\n";
|
ss << "\n";
|
||||||
indent_depth(depth, ss);
|
indent_depth(depth, ss);
|
||||||
if (n.right == -1)
|
if (n.right == -1)
|
||||||
ss << "()";
|
ss << "NIL";
|
||||||
else
|
else
|
||||||
ss << to_string(nodes[n.right], depth + 1);
|
ss << to_string(nodes[n.right], depth + 1);
|
||||||
ss << ")";
|
ss << ")";
|
||||||
|
|||||||
Reference in New Issue
Block a user