kptree Namespace Reference


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="")


Function Documentation

template<class T>
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    }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
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    }

Here is the call graph for this function:


Generated on Wed Feb 27 20:32:51 2008 for php.ast.svn.src. by  doxygen 1.5.3