Functions | |
template<class T> | |
void | print_tree_bracketed (const tree< T > &t, std::ostream &str) |
template<class T> | |
void | print_subtree_bracketed (const tree< T > &t, typename tree< T >::iterator iRoot, std::ostream &str, std::string padding="") |
void kptree::print_subtree_bracketed | ( | const tree< T > & | t, | |
typename tree< T >::iterator | iRoot, | |||
std::ostream & | str, | |||
std::string | padding = "" | |||
) | [inline] |
Definition at line 51 of file tree_util.h.
References tree< T, tree_node_allocator >::begin(), tree< T, tree_node_allocator >::empty(), tree< T, tree_node_allocator >::end(), and tree< T, tree_node_allocator >::number_of_children().
Referenced by print_tree_bracketed().
00052 { 00053 if(t.empty()) return; 00054 if (t.number_of_children(iRoot) == 0) { 00055 str << padding << *iRoot << std::endl; 00056 } 00057 else { 00058 // parent 00059 str << padding << *iRoot << std::endl; 00060 // child1, ..., childn 00061 int siblingNum; 00062 typename tree<T>::sibling_iterator iChildren; 00063 for (iChildren = t.begin(iRoot), siblingNum = 0; iChildren != t.end(iRoot); ++iChildren) { 00064 // recursively print child 00065 print_subtree_bracketed(t,iChildren,str, padding + " "); 00066 // comma after every child except the last one 00067 } 00068 } 00069 }
void kptree::print_tree_bracketed | ( | const tree< T > & | t, | |
std::ostream & | str | |||
) | [inline] |
Definition at line 36 of file tree_util.h.
References tree< T, tree_node_allocator >::begin(), tree< T, tree_node_allocator >::end(), tree< T, tree_node_allocator >::number_of_siblings(), and print_subtree_bracketed().
00037 { 00038 int headCount = t.number_of_siblings(t.begin()); 00039 int headNum = 0; 00040 for(typename tree<T>::sibling_iterator iRoots = t.begin(); iRoots != t.end(); iRoots++) { 00041 print_subtree_bracketed(t,iRoots,str,""); 00042 if (headNum <= headCount - 1) { 00043 str << std::endl; 00044 } 00045 } 00046 }