35 lines
No EOL
728 B
C++
35 lines
No EOL
728 B
C++
#include "tree.hpp"
|
|
#include <string>
|
|
|
|
void test_tree() {
|
|
Tree<std::string> tree;
|
|
|
|
auto* virus = tree.create_leaf("Virus");
|
|
auto* worm = tree.create_leaf("Worm");
|
|
|
|
auto* test = virus->create_leaf("test");
|
|
|
|
test->create_leaf("a");
|
|
test->create_leaf("b");
|
|
test->create_leaf("c");
|
|
test->create_leaf("884");
|
|
|
|
tree.walk([](auto* node) {
|
|
auto tab_count = node->parent_count();
|
|
auto& data = node->data();
|
|
|
|
for(auto i = 0; i < tab_count; ++i)
|
|
std::printf("\t");
|
|
|
|
if(node->is_root()) {
|
|
std::printf("(root)\n");
|
|
} else {
|
|
std::printf("%s\n", data.c_str());
|
|
}
|
|
});
|
|
}
|
|
|
|
int main() {
|
|
test_tree();
|
|
return 0;
|
|
} |