56     : parent(0), first_child(0), last_child(0), prev_sibling(0), next_sibling(0)
 
   62     : parent(0), first_child(0), last_child(0), prev_sibling(0), next_sibling(0), data(val)
 
   66 template <
class T, 
class tree_node_allocator = std::allocator<tree_node_<T> > >
 
   75         class pre_order_iterator;
 
   76         class post_order_iterator;
 
   77         class sibling_iterator;
 
   82         tree(
const iterator_base&);
 
   89         class iterator_base : 
public stlport::bidirectional_iterator<T, ptrdiff_t> {
 
  219                 tree_node *range_first() 
const;
 
  220                 tree_node *range_last() 
const;
 
  276         template<
typename   iter> 
static iter 
parent(iter);
 
  287         template<
typename iter> iter 
erase(iter);
 
  292         template<
typename iter> iter 
append_child(iter position); 
 
  295         template<
typename iter> iter 
append_child(iter position, 
const T& x);
 
  296         template<
typename iter> iter 
prepend_child(iter position, 
const T& x);
 
  298         template<
typename iter> iter 
append_child(iter position, iter other_position);
 
  299         template<
typename iter> iter 
prepend_child(iter position, iter other_position);
 
  307         template<
typename iter> iter 
insert(iter position, 
const T& x);
 
  313         template<
typename iter> iter 
insert_after(iter position, 
const T& x);
 
  318         template<
typename iter> iter 
replace(iter position, 
const T& x);
 
  326         template<
typename iter> iter 
flatten(iter position);
 
  330         template<
typename iter> iter 
reparent(iter position, iter from);
 
  333         template<
typename iter> iter 
wrap(iter position, 
const T& x);
 
  336         template<
typename iter> iter 
move_after(iter target, iter source);
 
  338       template<
typename iter> iter 
move_before(iter target, iter source);
 
  341         template<
typename iter> iter 
move_ontop(iter target, iter source);
 
  345                             bool duplicate_leaves=
false);
 
  348         template<
class StrictWeakOrdering>
 
  351         template<
typename iter>
 
  352         bool     equal(
const iter& one, 
const iter& two, 
const iter& three) 
const;
 
  353         template<
typename iter, 
class BinaryPredicate>
 
  354         bool     equal(
const iter& one, 
const iter& two, 
const iter& three, BinaryPredicate) 
const;
 
  355         template<
typename iter>
 
  357         template<
typename iter, 
class BinaryPredicate>
 
  358         bool     equal_subtree(
const iter& one, 
const iter& two, BinaryPredicate) 
const;
 
  365        void     swap(iterator, iterator);
 
  420         template<
class StrictWeakOrdering>
 
  476 template <
class T, 
class tree_node_allocator>
 
  482 template <
class T, 
class tree_node_allocator>
 
  489 template <
class T, 
class tree_node_allocator>
 
  497 template <
class T, 
class tree_node_allocator>
 
  507 template <
class T, 
class tree_node_allocator>
 
  528 template <
class T, 
class tree_node_allocator>
 
  536 template <
class T, 
class tree_node_allocator>
 
  543 template <
class T, 
class tree_node_allocator>
 
  548     while(it!=other.
end()) {
 
  555     while(it!=other.
end()) {
 
  564 template <
class T, 
class tree_node_allocator>
 
  572 template<
class T, 
class tree_node_allocator> 
 
  576     if(it.node==0) 
return;
 
  578     tree_node *cur=it.node->first_child;
 
  587         alloc_.deallocate(prev,1);
 
  589     it.node->first_child=0;
 
  590     it.node->last_child=0;
 
  594 template<
class T, 
class tree_node_allocator> 
 
  598     tree_node *cur=it.node;
 
  623 template <
class T, 
class tree_node_allocator>
 
  629 template <
class T, 
class tree_node_allocator>
 
  635 template <
class T, 
class tree_node_allocator>
 
  641 template <
class T, 
class tree_node_allocator>
 
  647 template <
class T, 
class tree_node_allocator>
 
  658 template <
class T, 
class tree_node_allocator>
 
  664 template <
class T, 
class tree_node_allocator>
 
  670     tree_node *tmp=pos.node;
 
  671     unsigned int curdepth=0;
 
  678                        throw std::range_error(
"tree: begin_fixed out of range");
 
  681                        throw std::range_error(
"tree: begin_fixed out of range");
 
  695 template <
class T, 
class tree_node_allocator>
 
  699     tree_node *tmp=pos.node;
 
  700     unsigned int curdepth=1;
 
  705                 throw std::range_error(
"tree: end_fixed out of range");
 
  713 template <
class T, 
class tree_node_allocator>
 
  717     if(pos.node->first_child==0) {
 
  720     return pos.node->first_child;
 
  723 template <
class T, 
class tree_node_allocator>
 
  731 template <
class T, 
class tree_node_allocator>
 
  742 template <
class T, 
class tree_node_allocator>
 
  748 template <
class T, 
class tree_node_allocator>
 
  751     tree_node *tmp=top.node;
 
  757 template <
class T, 
class tree_node_allocator>
 
  763 template <
class T, 
class tree_node_allocator>
 
  764 template <
typename iter>
 
  767     assert(position.node!=0);
 
  768     return iter(position.node->parent);
 
  771 template <
class T, 
class tree_node_allocator>
 
  772 template <
typename iter>
 
  775     assert(position.node!=0);
 
  777     ret.node=position.node->prev_sibling;
 
  781 template <
class T, 
class tree_node_allocator>
 
  782 template <
typename iter>
 
  785     assert(position.node!=0);
 
  787     ret.node=position.node->next_sibling;
 
  791 template <
class T, 
class tree_node_allocator>
 
  792 template <
typename iter>
 
  836 template <
class T, 
class tree_node_allocator>
 
  837 template <
typename iter>
 
  840     assert(position.node!=
head);
 
  841     assert(position.node!=
feet);
 
  842     assert(position.node);
 
  844     tree_node *tmp=
alloc_.allocate(1,0);
 
  850     tmp->
parent=position.node;
 
  851     if(position.node->last_child!=0) {
 
  852         position.node->last_child->next_sibling=tmp;
 
  858     position.node->last_child=tmp;
 
  863 template <
class T, 
class tree_node_allocator>
 
  864 template <
typename iter>
 
  867     assert(position.node!=
head);
 
  868     assert(position.node!=
feet);
 
  869     assert(position.node);
 
  871     tree_node *tmp=
alloc_.allocate(1,0);
 
  877     tmp->
parent=position.node;
 
  878     if(position.node->first_child!=0) {
 
  879         position.node->first_child->prev_sibling=tmp;
 
  885     position.node->prev_child=tmp;
 
  890 template <
class T, 
class tree_node_allocator>
 
  891 template <
class iter>
 
  898     assert(position.node!=
head);
 
  899     assert(position.node!=
feet);
 
  900     assert(position.node);
 
  902     tree_node* tmp = 
alloc_.allocate(1,0);
 
  908     tmp->
parent=position.node;
 
  909     if(position.node->last_child!=0) {
 
  910         position.node->last_child->next_sibling=tmp;
 
  916     position.node->last_child=tmp;
 
  921 template <
class T, 
class tree_node_allocator>
 
  922 template <
class iter>
 
  925     assert(position.node!=
head);
 
  926     assert(position.node!=
feet);
 
  927     assert(position.node);
 
  929     tree_node* tmp = 
alloc_.allocate(1,0);
 
  935     tmp->
parent=position.node;
 
  936     if(position.node->first_child!=0) {
 
  937         position.node->first_child->prev_sibling=tmp;
 
  943     position.node->first_child=tmp;
 
  948 template <
class T, 
class tree_node_allocator>
 
  949 template <
class iter>
 
  952     assert(position.node!=
head);
 
  953     assert(position.node!=
feet);
 
  954     assert(position.node);
 
  960 template <
class T, 
class tree_node_allocator>
 
  961 template <
class iter>
 
  964     assert(position.node!=
head);
 
  965     assert(position.node!=
feet);
 
  966     assert(position.node);
 
  972 template <
class T, 
class tree_node_allocator>
 
  973 template <
class iter>
 
  976     assert(position.node!=
head);
 
  977     assert(position.node!=
feet);
 
  978     assert(position.node);
 
  989 template <
class T, 
class tree_node_allocator>
 
  990 template <
class iter>
 
  993     assert(position.node!=
head);
 
  994     assert(position.node!=
feet);
 
  995     assert(position.node);
 
 1006 template <
class T, 
class tree_node_allocator>
 
 1013 template <
class T, 
class tree_node_allocator>
 
 1014 template <
class iter>
 
 1017     if(position.node==0) {
 
 1021     tree_node* tmp = 
alloc_.allocate(1,0);
 
 1022     alloc_.construct(tmp, x);
 
 1027     tmp->
parent=position.node->parent;
 
 1030     position.node->prev_sibling=tmp;
 
 1034             tmp->
parent->first_child=tmp;
 
 1041 template <
class T, 
class tree_node_allocator>
 
 1044     tree_node* tmp = 
alloc_.allocate(1,0);
 
 1045     alloc_.construct(tmp, x);
 
 1051     if(position.
node==0) { 
 
 1054         tmp->
parent->last_child=tmp;
 
 1064             tmp->
parent->first_child=tmp;
 
 1071 template <
class T, 
class tree_node_allocator>
 
 1072 template <
class iter>
 
 1075     tree_node* tmp = 
alloc_.allocate(1,0);
 
 1076     alloc_.construct(tmp, x);
 
 1081     tmp->
parent=position.node->parent;
 
 1084     position.node->next_sibling=tmp;
 
 1088             tmp->
parent->last_child=tmp;
 
 1096 template <
class T, 
class tree_node_allocator>
 
 1097 template <
class iter>
 
 1106 template <
class T, 
class tree_node_allocator>
 
 1107 template <
class iter>
 
 1126 template <
class T, 
class tree_node_allocator>
 
 1127 template <
class iter>
 
 1132     position.node->data=x;
 
 1138 template <
class T, 
class tree_node_allocator>
 
 1139 template <
class iter>
 
 1142     assert(position.node!=
head);
 
 1143     tree_node *current_from=from.node;
 
 1144     tree_node *start_from=from.node;
 
 1145     tree_node *current_to  =position.node;
 
 1151     tree_node* tmp = 
alloc_.allocate(1,0);
 
 1152     alloc_.construct(tmp, (*from));
 
 1157         if(current_to->
parent!=0)
 
 1158             current_to->
parent->first_child=tmp;
 
 1165         if(current_to->
parent!=0)
 
 1166             current_to->
parent->last_child=tmp;
 
 1174     alloc_.destroy(current_to);
 
 1175     alloc_.deallocate(current_to,1);
 
 1179     tree_node *last=from.node->next_sibling;
 
 1184         assert(current_from!=0);
 
 1190             while(current_from->
next_sibling==0 && current_from!=start_from) {
 
 1191                 current_from=current_from->
parent;
 
 1193                 assert(current_from!=0);
 
 1196             if(current_from!=last) {
 
 1200         } 
while(current_from!=last);
 
 1205 template <
class T, 
class tree_node_allocator>
 
 1212     tree_node *orig_first=orig_begin.
node;
 
 1213     tree_node *new_first=new_begin.
node;
 
 1214     tree_node *orig_last=orig_first;
 
 1215     while((++orig_begin)!=orig_end)
 
 1217     tree_node *new_last=new_first;
 
 1218     while((++new_begin)!=new_end)
 
 1230         if(new_first==new_last)
 
 1237     tree_node *next=orig_first;
 
 1250 template <
class T, 
class tree_node_allocator>
 
 1251 template <
typename iter>
 
 1254     if(position.node->first_child==0)
 
 1257     tree_node *tmp=position.node->first_child;
 
 1259         tmp->
parent=position.node->parent;
 
 1262     if(position.node->next_sibling) {
 
 1263         position.node->last_child->next_sibling=position.node->next_sibling;
 
 1264         position.node->next_sibling->prev_sibling=position.node->last_child;
 
 1267         position.node->parent->last_child=position.node->last_child;
 
 1269     position.node->next_sibling=position.node->first_child;
 
 1270     position.node->next_sibling->prev_sibling=position.node;
 
 1271     position.node->first_child=0;
 
 1272     position.node->last_child=0;
 
 1278 template <
class T, 
class tree_node_allocator>
 
 1279 template <
typename iter>
 
 1282     tree_node *first=begin.
node;
 
 1283     tree_node *last=first;
 
 1285     assert(first!=position.node);
 
 1287     if(begin==end) 
return begin;
 
 1289     while((++begin)!=end) {
 
 1305     if(position.node->first_child==0) {
 
 1306         position.node->first_child=first;
 
 1311         position.node->last_child->next_sibling=first;
 
 1313         position.node->last_child=last;
 
 1317     tree_node *pos=first;
 
 1319         pos->
parent=position.node;
 
 1320         if(pos==last) 
break;
 
 1327 template <
class T, 
class tree_node_allocator>
 
 1330     if(from.node->first_child==0) 
return position;
 
 1331     return reparent(position, from.node->first_child, 
end(from));
 
 1334 template <
class T, 
class tree_node_allocator>
 
 1337     assert(position.node!=0);
 
 1340     iter ret = 
insert(position, x);
 
 1345 template <
class T, 
class tree_node_allocator>
 
 1348    tree_node *dst=target.node;
 
 1349    tree_node *src=source.node;
 
 1353    if(dst==src) 
return source;
 
 1366    else                     dst->
parent->last_child=src;
 
 1374 template <
class T, 
class tree_node_allocator>
 
 1377    tree_node *dst=target.node;
 
 1378    tree_node *src=source.node;
 
 1382    if(dst==src) 
return source;
 
 1395    else                     dst->
parent->first_child=src;
 
 1404 template <
class T, 
class tree_node_allocator>
 
 1408     tree_node *dst=target.
node;
 
 1409     tree_node *src=source.
node;
 
 1410     tree_node *dst_prev_sibling;
 
 1413         assert(dst_prev_sibling);
 
 1418     if(dst==src) 
return source;
 
 1419     if(dst_prev_sibling)
 
 1420         if(dst_prev_sibling==src) 
 
 1430     if(dst_prev_sibling!=0) dst_prev_sibling->
next_sibling=src;
 
 1441 template <
class T, 
class tree_node_allocator>
 
 1444     tree_node *dst=target.node;
 
 1445     tree_node *src=source.node;
 
 1449     if(dst==src) 
return source;
 
 1458     tree_node *b_parent=dst->
parent;
 
 1470     if(b_prev_sibling!=0) b_prev_sibling->
next_sibling=src;
 
 1472     if(b_next_sibling!=0) b_next_sibling->
prev_sibling=src;
 
 1480 template <
class T, 
class tree_node_allocator>
 
 1483                                                         bool duplicate_leaves)
 
 1486     while(from1!=from2) {
 
 1487         if((fnd=std::find(to1, to2, (*from1))) != to2) { 
 
 1489                 if(duplicate_leaves)
 
 1504 template <
class T, 
class tree_node_allocator>
 
 1508     sort(from, to, comp, deep);
 
 1511 template <
class T, 
class tree_node_allocator>
 
 1512 template <
class StrictWeakOrdering>
 
 1514                                                      StrictWeakOrdering comp, 
bool deep)
 
 1516     if(from==to) 
return;
 
 1520     std::multiset<tree_node *, compare_nodes<StrictWeakOrdering> > nodes(comp);
 
 1523         nodes.insert(it.
node);
 
 1531     tree_node *next=it2.node->next_sibling;
 
 1532     typename std::multiset<tree_node *, compare_nodes<StrictWeakOrdering> >
::iterator nit=nodes.
begin(), eit=nodes.
end();
 
 1534         if((*nit)->parent!=0) 
 
 1535             (*nit)->parent->first_child=(*nit);
 
 1541         (*nit)->prev_sibling=prev;
 
 1552     (*eit)->next_sibling=next;
 
 1555         if((*eit)->parent!=0) 
 
 1556             (*eit)->
parent->last_child=(*eit);
 
 1571 template <
class T, 
class tree_node_allocator>
 
 1572 template <
typename iter>
 
 1575     std::equal_to<T> comp;
 
 1576     return equal(one_, two, three_, comp);
 
 1579 template <
class T, 
class tree_node_allocator>
 
 1580 template <
typename iter>
 
 1583     std::equal_to<T> comp;
 
 1587 template <
class T, 
class tree_node_allocator>
 
 1588 template <
typename iter, 
class BinaryPredicate>
 
 1595     while(one!=two && 
is_valid(three)) {
 
 1596         if(!fun(*one,*three))
 
 1606 template <
class T, 
class tree_node_allocator>
 
 1607 template <
typename iter, 
class BinaryPredicate>
 
 1612     if(!fun(*one,*two)) 
return false;
 
 1617 template <
class T, 
class tree_node_allocator>
 
 1626 template <
class T, 
class tree_node_allocator>
 
 1633 template <
class T, 
class tree_node_allocator>
 
 1645 template <
class T, 
class tree_node_allocator>
 
 1650     eit.skip_children();
 
 1659 template <
class T, 
class tree_node_allocator>
 
 1666 template <
class T, 
class tree_node_allocator>
 
 1669     tree_node* pos=it.node;
 
 1679 template <
class T, 
class tree_node_allocator>
 
 1682     tree_node* pos=it.node;
 
 1685     while(pos->
parent!=0 && pos!=root.node) {
 
 1692 template <
class T, 
class tree_node_allocator>
 
 1703 template <
class T, 
class tree_node_allocator>
 
 1706     tree_node *tmp=pos.node;
 
 1708     if(tmp==0 || tmp==
head || tmp==
feet) 
return -1;
 
 1710     int curdepth=0, maxdepth=0;
 
 1713             if(tmp==pos.node) 
return maxdepth;
 
 1718                if(tmp==0) 
return maxdepth;
 
 1722          if(tmp==pos.node) 
return maxdepth;
 
 1727         maxdepth=std::max(curdepth, maxdepth);
 
 1731 template <
class T, 
class tree_node_allocator>
 
 1734     tree_node *pos=it.node->first_child;
 
 1735     if(pos==0) 
return 0;
 
 1747 template <
class T, 
class tree_node_allocator>
 
 1750     tree_node *pos=it.node;
 
 1771 template <
class T, 
class tree_node_allocator>
 
 1792 template <
class T, 
class tree_node_allocator>
 
 1839 template <
class T, 
class tree_node_allocator>
 
 1846         if(tmp==it) 
return true;
 
 1852 template <
class T, 
class tree_node_allocator>
 
 1855     if(it.node==0 || it.node==
feet || it.node==
head) 
return false;
 
 1859 template <
class T, 
class tree_node_allocator>
 
 1863     std::set<iterator, iterator_base_less> parents;
 
 1869         parents.insert(walk);
 
 1876         if(parents.find(walk) != parents.end()) 
break;
 
 1882 template <
class T, 
class tree_node_allocator>
 
 1901 template <
class T, 
class tree_node_allocator>
 
 1905    if(it.node->parent==0) {
 
 1913       tmp=it.node->parent->first_child;
 
 1923 template <
class T, 
class tree_node_allocator>
 
 1942 template <
class T, 
class tree_node_allocator>
 
 1945     tree_node *tmp=it.node->first_child;
 
 1958 template <
class T, 
class tree_node_allocator>
 
 1960     : node(0), skip_current_children_(false)
 
 1964 template <
class T, 
class tree_node_allocator>
 
 1966     : node(tn), skip_current_children_(false)
 
 1970 template <
class T, 
class tree_node_allocator>
 
 1976 template <
class T, 
class tree_node_allocator>
 
 1979     return &(node->data);
 
 1982 template <
class T, 
class tree_node_allocator>
 
 1985     if(other.
node!=this->node) 
return true;
 
 1989 template <
class T, 
class tree_node_allocator>
 
 1992     if(other.
node==this->node) 
return true;
 
 1996 template <
class T, 
class tree_node_allocator>
 
 1999     if(other.
node!=this->node) 
return true;
 
 2003 template <
class T, 
class tree_node_allocator>
 
 2006     if(other.
node==this->node) 
return true;
 
 2010 template <
class T, 
class tree_node_allocator>
 
 2013     if(other.
node!=this->node) 
return true;
 
 2017 template <
class T, 
class tree_node_allocator>
 
 2020     if(other.
node==this->node) 
return true;
 
 2024 template <
class T, 
class tree_node_allocator>
 
 2027    if(other.
node!=this->node) 
return true;
 
 2031 template <
class T, 
class tree_node_allocator>
 
 2034    if(other.
node==this->node && other.
top_node==this->top_node) 
return true;
 
 2038 template <
class T, 
class tree_node_allocator>
 
 2041     if(node->first_child==0) 
 
 2049 template <
class T, 
class tree_node_allocator>
 
 2057 template <
class T, 
class tree_node_allocator>
 
 2060     skip_current_children_=
true;
 
 2063 template <
class T, 
class tree_node_allocator>
 
 2066    skip_current_children_=skip;
 
 2069 template <
class T, 
class tree_node_allocator>
 
 2072     tree_node *pos=node->first_child;
 
 2073     if(pos==0) 
return 0;
 
 2087 template <
class T, 
class tree_node_allocator>
 
 2093 template <
class T, 
class tree_node_allocator>
 
 2099 template <
class T, 
class tree_node_allocator>
 
 2105 template <
class T, 
class tree_node_allocator>
 
 2119 template <
class T, 
class tree_node_allocator>
 
 2122     assert(this->node!=0);
 
 2123     if(!this->skip_current_children_ && this->node->first_child != 0) {
 
 2124         this->node=this->node->first_child;
 
 2127         this->skip_current_children_=
false;
 
 2128         while(this->node->next_sibling==0) {
 
 2129             this->node=this->node->parent;
 
 2133         this->node=this->node->next_sibling;
 
 2138 template <
class T, 
class tree_node_allocator>
 
 2141     assert(this->node!=0);
 
 2142     if(this->node->prev_sibling) {
 
 2143         this->node=this->node->prev_sibling;
 
 2144         while(this->node->last_child)
 
 2145             this->node=this->node->last_child;
 
 2148         this->node=this->node->parent;
 
 2155 template <
class T, 
class tree_node_allocator>
 
 2163 template <
class T, 
class tree_node_allocator>
 
 2171 template <
class T, 
class tree_node_allocator>
 
 2181 template <
class T, 
class tree_node_allocator>
 
 2195 template <
class T, 
class tree_node_allocator>
 
 2201 template <
class T, 
class tree_node_allocator>
 
 2207 template <
class T, 
class tree_node_allocator>
 
 2213 template <
class T, 
class tree_node_allocator>
 
 2227 template <
class T, 
class tree_node_allocator>
 
 2230     assert(this->node!=0);
 
 2231     if(this->node->next_sibling==0) {
 
 2232         this->node=this->node->parent;
 
 2233         this->skip_current_children_=
false;
 
 2236         this->node=this->node->next_sibling;
 
 2237         if(this->skip_current_children_) {
 
 2238             this->skip_current_children_=
false;
 
 2241             while(this->node->first_child)
 
 2242                 this->node=this->node->first_child;
 
 2248 template <
class T, 
class tree_node_allocator>
 
 2251     assert(this->node!=0);
 
 2252     if(this->skip_current_children_ || this->node->last_child==0) {
 
 2253         this->skip_current_children_=
false;
 
 2254         while(this->node->prev_sibling==0)
 
 2255             this->node=this->node->parent;
 
 2256         this->node=this->node->prev_sibling;
 
 2259         this->node=this->node->last_child;
 
 2264 template <
class T, 
class tree_node_allocator>
 
 2272 template <
class T, 
class tree_node_allocator>
 
 2281 template <
class T, 
class tree_node_allocator>
 
 2291 template <
class T, 
class tree_node_allocator>
 
 2301 template <
class T, 
class tree_node_allocator>
 
 2304     assert(this->node!=0);
 
 2305     while(this->node->first_child)
 
 2306         this->node=this->node->first_child;
 
 2312 template <
class T, 
class tree_node_allocator>
 
 2318 template <
class T, 
class tree_node_allocator>
 
 2325 template <
class T, 
class tree_node_allocator>
 
 2332 template <
class T, 
class tree_node_allocator>
 
 2335     if(other.
node!=this->node) 
return true;
 
 2339 template <
class T, 
class tree_node_allocator>
 
 2342     if(other.
node==this->node) 
return true;
 
 2346 template <
class T, 
class tree_node_allocator>
 
 2349     assert(this->node!=0);
 
 2353     while(sib!=this->
end()) {
 
 2354         traversal_queue.push(sib.
node);
 
 2357     traversal_queue.pop();
 
 2358     if(traversal_queue.size()>0)
 
 2359         this->node=traversal_queue.front();
 
 2365 template <
class T, 
class tree_node_allocator>
 
 2373 template <
class T, 
class tree_node_allocator>
 
 2387 template <
class T, 
class tree_node_allocator>
 
 2393 template <
class T, 
class tree_node_allocator>
 
 2399 template <
class T, 
class tree_node_allocator>
 
 2405 template <
class T, 
class tree_node_allocator>
 
 2411 template <
class T, 
class tree_node_allocator>
 
 2417 template <
class T, 
class tree_node_allocator>
 
 2420     if(other.
node==this->node && other.
top_node==top_node) 
return true;
 
 2424 template <
class T, 
class tree_node_allocator>
 
 2427     if(other.
node!=this->node || other.
top_node!=top_node) 
return true;
 
 2431 template <
class T, 
class tree_node_allocator>
 
 2434     assert(this->node!=0);
 
 2436     if(this->node->next_sibling) {
 
 2437         this->node=this->node->next_sibling;
 
 2440         int relative_depth=0;
 
 2443             if(this->node==this->top_node) {
 
 2447             this->node=this->node->parent;
 
 2448             if(this->node==0) 
return *
this;
 
 2450             } 
while(this->node->next_sibling==0);
 
 2452         this->node=this->node->next_sibling;
 
 2453         while(this->node->first_child==0) {
 
 2454             if(this->node->next_sibling==0)
 
 2456             this->node=this->node->next_sibling;
 
 2457             if(this->node==0) 
return *
this;
 
 2459         while(relative_depth<0 && this->node->first_child!=0) {
 
 2460             this->node=this->node->first_child;
 
 2463         if(relative_depth<0) {
 
 2464             if(this->node->next_sibling==0) 
goto upper;
 
 2471 template <
class T, 
class tree_node_allocator>
 
 2474     assert(this->node!=0);
 
 2476     if(this->node->prev_sibling) {
 
 2477         this->node=this->node->prev_sibling;
 
 2480         int relative_depth=0;
 
 2483             if(this->node==this->top_node) {
 
 2487             this->node=this->node->parent;
 
 2488             if(this->node==0) 
return *
this;
 
 2490             } 
while(this->node->prev_sibling==0);
 
 2492         this->node=this->node->prev_sibling;
 
 2493         while(this->node->last_child==0) {
 
 2494             if(this->node->prev_sibling==0)
 
 2496             this->node=this->node->prev_sibling;
 
 2497             if(this->node==0) 
return *
this;
 
 2499         while(relative_depth<0 && this->node->last_child!=0) {
 
 2500             this->node=this->node->last_child;
 
 2503         if(relative_depth<0) {
 
 2504             if(this->node->prev_sibling==0) 
goto upper;
 
 2533 template <
class T, 
class tree_node_allocator>
 
 2541 template <
class T, 
class tree_node_allocator>
 
 2549 template <
class T, 
class tree_node_allocator>
 
 2559 template <
class T, 
class tree_node_allocator>
 
 2572 template <
class T, 
class tree_node_allocator>
 
 2579 template <
class T, 
class tree_node_allocator>
 
 2586 template <
class T, 
class tree_node_allocator>
 
 2593 template <
class T, 
class tree_node_allocator>
 
 2599 template <
class T, 
class tree_node_allocator>
 
 2603     if(this->node==0) 
return;
 
 2604     if(this->node->parent!=0)
 
 2605         parent_=this->node->parent;
 
 2608 template <
class T, 
class tree_node_allocator>
 
 2612         this->node=this->node->next_sibling;
 
 2616 template <
class T, 
class tree_node_allocator>
 
 2619     if(this->node) this->node=this->node->prev_sibling;
 
 2622         this->node=parent_->last_child;
 
 2627 template <
class T, 
class tree_node_allocator>
 
 2635 template <
class T, 
class tree_node_allocator>
 
 2643 template <
class T, 
class tree_node_allocator>
 
 2653 template <
class T, 
class tree_node_allocator>
 
 2663 template <
class T, 
class tree_node_allocator>
 
 2670 template <
class T, 
class tree_node_allocator>
 
 2678 template <
class T, 
class tree_node_allocator>
 
 2684 template <
class T, 
class tree_node_allocator>
 
 2690 template <
class T, 
class tree_node_allocator>
 
 2696 template <
class T, 
class tree_node_allocator>
 
 2709 template <
class T, 
class tree_node_allocator>
 
 2712     assert(this->node!=0);
 
 2713     if(this->node->first_child!=0) { 
 
 2714          while(this->node->first_child) 
 
 2715               this->node=this->node->first_child;
 
 2718          while(this->node->next_sibling==0) { 
 
 2719               if (this->node->parent==0) 
return *
this;
 
 2720               this->node=this->node->parent;
 
 2721               if (top_node != 0 && this->node==top_node) 
return *
this;
 
 2723          this->node=this->node->next_sibling;
 
 2724          while(this->node->first_child)
 
 2725               this->node=this->node->first_child;
 
 2730 template <
class T, 
class tree_node_allocator>
 
 2733     assert(this->node!=0);
 
 2734     while (this->node->prev_sibling==0) {
 
 2735         if (this->node->parent==0) 
return *
this;
 
 2736         this->node=this->node->parent;
 
 2737         if (top_node !=0 && this->node==top_node) 
return *
this; 
 
 2739     this->node=this->node->prev_sibling;
 
 2740     while(this->node->last_child)
 
 2741         this->node=this->node->last_child;
 
 2745 template <
class T, 
class tree_node_allocator>
 
 2753 template <
class T, 
class tree_node_allocator>
 
 2762 template <
class T, 
class tree_node_allocator>
 
 2772 template <
class T, 
class tree_node_allocator>
 
void clear()
Erase all nodes of the tree. 
Definition: tree.hh:565
iter replace(iter position, const T &x)
Replace node at 'position' with other node (keeping same children); 'position' becomes invalid...
Definition: tree.hh:1128
Breadth-first iterator, using a queue. 
Definition: tree.hh:161
sibling_iterator & operator-=(unsigned int)
Definition: tree.hh:2654
breadth_first_queued_iterator & operator++()
Definition: tree.hh:2347
void swap(sibling_iterator it)
Exchange the node (plus subtree) with its sibling node (do nothing if no sibling present). 
Definition: tree.hh:1772
fixed_depth_iterator & operator-=(unsigned int)
Definition: tree.hh:2550
bool operator!=(const sibling_iterator &) const 
Definition: tree.hh:2011
pre_order_iterator & operator++()
Definition: tree.hh:2120
leaf_iterator & operator++()
Definition: tree.hh:2710
fixed_depth_iterator end_fixed(const iterator_base &, unsigned int) const 
Return fixed-depth end iterator. 
Definition: tree.hh:696
breadth_first_queued_iterator()
Definition: tree.hh:2313
void erase_children(const iterator_base &)
Erase all children of the node pointed to by iterator. 
Definition: tree.hh:573
T * pointer
Definition: tree.hh:95
tree_node_< T > * prev_sibling
Definition: tree.hh:50
bool operator==(const breadth_first_queued_iterator &) const 
Definition: tree.hh:2340
tree()
Definition: tree.hh:477
iter reparent(iter position, sibling_iterator begin, sibling_iterator end)
Move nodes in range to be children of 'position'. 
Definition: tree.hh:1280
post_order_iterator begin_post() const 
Return post-order iterator to the beginning of the tree. 
Definition: tree.hh:648
iter erase(iter)
Erase element at position pointed to by iterator, return incremented iterator. 
Definition: tree.hh:596
iterator_base()
Definition: tree.hh:1959
tree_node * range_first() const 
Definition: tree.hh:2664
int max_depth() const 
Determine the maximal depth of the tree. An empty tree has max_depth=-1. 
Definition: tree.hh:1693
pre_order_iterator & operator--()
Definition: tree.hh:2139
size_t size_type
Definition: tree.hh:97
fixed_depth_iterator & operator++()
Definition: tree.hh:2432
unsigned int number_of_children() const 
Number of children of the node pointed to by the iterator. 
Definition: tree.hh:2070
pre_order_iterator set_head(const T &x)
Short-hand to insert topmost node in otherwise empty tree. 
Definition: tree.hh:1007
~tree()
Definition: tree.hh:498
bool operator==(const fixed_depth_iterator &) const 
Definition: tree.hh:2418
tree_node_allocator alloc_
Definition: tree.hh:415
bool equal_subtree(const iter &one, const iter &two) const 
Definition: tree.hh:1581
void copy_(const tree< T, tree_node_allocator > &other)
Definition: tree.hh:544
void skip_children()
When called, the next increment/decrement skips children of this node. 
Definition: tree.hh:2058
iter flatten(iter position)
Move all children of node at 'position' to be siblings, returns position. 
Definition: tree.hh:1252
static unsigned int number_of_children(const iterator_base &)
Count the number of children of node at position. 
Definition: tree.hh:1732
pre_order_iterator()
Definition: tree.hh:2088
sibling_iterator & operator+=(unsigned int)
Definition: tree.hh:2644
tree subtree(sibling_iterator from, sibling_iterator to) const 
Extract a new tree formed by the range of siblings plus all their children. 
Definition: tree.hh:1618
bool operator!=(const post_order_iterator &) const 
Definition: tree.hh:1983
tree_node * node
Definition: tree.hh:116
static int depth(const iterator_base &)
Compute the depth to the root or to a fixed other iterator. 
Definition: tree.hh:1667
post_order_iterator & operator--()
Definition: tree.hh:2249
tree_node * head
Definition: tree.hh:413
Comparator class for two nodes of a tree (used for sorting and searching). 
Definition: tree.hh:421
iter move_before(iter target, iter source)
Move 'source' node (plus its children) to become the previous sibling of 'target'. 
Definition: tree.hh:1375
sibling_iterator & operator++()
Definition: tree.hh:2609
bool empty() const 
Check if tree is empty. 
Definition: tree.hh:1660
tree_node_< T > * next_sibling
Definition: tree.hh:50
T value_type
Definition: tree.hh:94
post_order_iterator & operator+=(unsigned int)
Definition: tree.hh:2282
Iterator which traverses only the nodes which are siblings of each other. 
Definition: tree.hh:203
post_order_iterator()
Definition: tree.hh:2196
bool operator!=(const breadth_first_queued_iterator &) const 
Definition: tree.hh:2333
leaf_iterator end_leaf() const 
Return leaf end iterator for entire tree. 
Definition: tree.hh:743
sibling_iterator sibling(const iterator_base &position, unsigned int)
Return iterator to the sibling indicated by index. 
Definition: tree.hh:1902
tree_node_< T > * first_child
Definition: tree.hh:49
bool operator!=(const leaf_iterator &) const 
Definition: tree.hh:2025
pre_order_iterator end() const 
Return iterator to the end of the tree. 
Definition: tree.hh:630
fixed_depth_iterator()
Definition: tree.hh:2388
sibling_iterator & operator--()
Definition: tree.hh:2617
tree_node * feet
Definition: tree.hh:413
static sibling_iterator child(const iterator_base &position, unsigned int)
Inverse of 'index': return the n-th child of the node at position. 
Definition: tree.hh:1943
T data
Definition: tree.hh:51
bool operator!=(const fixed_depth_iterator &) const 
Definition: tree.hh:2425
iter insert_after(iter position, const T &x)
Insert node as next sibling of node pointed to by position. 
Definition: tree.hh:1073
A node in the tree, combining links to other nodes as well as the actual data. 
Definition: tree.hh:43
post_order_iterator end_post() const 
Return post-order end iterator of the tree. 
Definition: tree.hh:659
leaf_iterator()
Definition: tree.hh:2679
breadth_first_queued_iterator begin_breadth_first() const 
Return breadth-first iterator to the first node at a given depth. 
Definition: tree.hh:636
tree_node * parent_
Definition: tree.hh:221
Base class for iterators, only pointers stored, no traversal logic. 
Definition: tree.hh:91
pre_order_iterator & operator-=(unsigned int)
Definition: tree.hh:2182
sibling_iterator end() const 
Definition: tree.hh:2050
pre_order_iterator begin() const 
Return iterator to the beginning of the tree. 
Definition: tree.hh:624
tree_node_< T > * last_child
Definition: tree.hh:49
iter previous_sibling(iter) const 
Return iterator to the previous sibling of a node. 
Definition: tree.hh:773
iter insert_subtree(iter position, const iterator_base &subtree)
Insert node (with children) pointed to by subtree as previous sibling of node pointed to by position...
Definition: tree.hh:1098
iter next_sibling(iter) const 
Return iterator to the next sibling of a node. 
Definition: tree.hh:783
bool equal(const iter &one, const iter &two, const iter &three) const 
Compare two ranges of nodes (compares nodes as well as tree structure). 
Definition: tree.hh:1573
Iterator which traverses only the leaves. 
Definition: tree.hh:227
breadth_first_queued_iterator breadth_first_iterator
Definition: tree.hh:179
bool is_in_subtree(const iterator_base &position, const iterator_base &begin, const iterator_base &end) const 
Determine whether node at position is in the subtrees with root in the range. 
Definition: tree.hh:1840
void debug_verify_consistency() const 
Definition: tree.hh:1924
leaf_iterator & operator-=(unsigned int)
Definition: tree.hh:2773
bool operator()(const tree_node *a, const tree_node *b)
Definition: tree.hh:425
bool operator==(const leaf_iterator &) const 
Definition: tree.hh:2032
void descend_all()
Set iterator to the first child as deep as possible down the tree. 
Definition: tree.hh:2302
sibling_iterator()
Definition: tree.hh:2573
bool is_valid(const iterator_base &) const 
Determine whether the iterator is an 'end' iterator and thus not actually pointing to a node...
Definition: tree.hh:1853
leaf_iterator begin_leaf() const 
Return leaf iterator to the first leaf of the tree. 
Definition: tree.hh:732
leaf_iterator & operator+=(unsigned int)
Definition: tree.hh:2763
void merge(sibling_iterator, sibling_iterator, sibling_iterator, sibling_iterator, bool duplicate_leaves=false)
Merge with other tree, creating new branches and leaves only if they are not already present...
Definition: tree.hh:1481
fixed_depth_iterator & operator--()
Definition: tree.hh:2472
Depth-first iterator, first accessing the children, then the node itself. 
Definition: tree.hh:140
T value_type
Value of the data stored at a node. 
Definition: tree.hh:72
tree_node_()
Definition: tree.hh:55
post_order_iterator & operator++()
Definition: tree.hh:2228
ptrdiff_t difference_type
Definition: tree.hh:98
unsigned int number_of_siblings(const iterator_base &) const 
Count the number of siblings (left and right) of node at iterator. Total nodes at this level is +1...
Definition: tree.hh:1748
breadth_first_queued_iterator & operator+=(unsigned int)
Definition: tree.hh:2374
iter append_child(iter position)
Insert empty node as last/first child of node pointed to by position. 
Definition: tree.hh:838
iter insert(iter position, const T &x)
Insert node as previous sibling of node pointed to by position. 
Definition: tree.hh:1015
bool skip_current_children_
Definition: tree.hh:118
unsigned int index(sibling_iterator it) const 
Determine the index of a node in the range of siblings to which it belongs. 
Definition: tree.hh:1883
std::bidirectional_iterator_tag iterator_category
Definition: tree.hh:99
post_order_iterator & operator-=(unsigned int)
Definition: tree.hh:2292
bool operator==(const post_order_iterator &) const 
Definition: tree.hh:1990
void sort(sibling_iterator from, sibling_iterator to, bool deep=false)
Sort (std::sort only moves values of nodes, this one moves children as well). 
Definition: tree.hh:1505
iter wrap(iter position, const T &x)
Replace node with a new node, making the old node a child of the new node. 
Definition: tree.hh:1335
Iterator which traverses only the nodes at a given depth from the root. 
Definition: tree.hh:182
fixed_depth_iterator begin_fixed(const iterator_base &, unsigned int) const 
Return fixed-depth iterator to the first node at a given depth from the given iterator. 
Definition: tree.hh:665
tree_node_< T > tree_node
Definition: tree.hh:69
void head_initialise_()
Definition: tree.hh:508
static iter parent(iter)
Return iterator to the parent of a node. 
Definition: tree.hh:765
iter move_ontop(iter target, iter source)
Move 'source' node (plus its children) to become the node at 'target' (erasing the node at 'target')...
Definition: tree.hh:1442
iter insert_subtree_after(iter position, const iterator_base &subtree)
Insert node (with children) pointed to by subtree as next sibling of node pointed to by position...
Definition: tree.hh:1108
sibling_iterator begin() const 
Definition: tree.hh:2039
tree_node_< T > * parent
Definition: tree.hh:48
tree_node * top_node
Definition: tree.hh:243
Depth-first iterator, first accessing the node, then its children. 
Definition: tree.hh:122
leaf_iterator & operator--()
Definition: tree.hh:2731
bool operator!=(const pre_order_iterator &) const 
Definition: tree.hh:1997
fixed_depth_iterator & operator+=(unsigned int)
Definition: tree.hh:2560
Comparator class for iterators (compares pointer values; why doesn't this work automatically?) 
Definition: tree.hh:405
iter prepend_children(iter position, sibling_iterator from, sibling_iterator to)
Definition: tree.hh:991
tree_node * top_node
Definition: tree.hh:199
bool operator==(const pre_order_iterator &) const 
Definition: tree.hh:2004
breadth_first_queued_iterator end_breadth_first() const 
Return breadth-first end iterator. 
Definition: tree.hh:642
bool operator()(const typename tree< T, tree_node_allocator >::iterator_base &one, const typename tree< T, tree_node_allocator >::iterator_base &two) const 
Definition: tree.hh:407
T & operator*() const 
Definition: tree.hh:1971
iter append_children(iter position, sibling_iterator from, sibling_iterator to)
Append the nodes in the from-to range (plus their children) as last/first children of position...
Definition: tree.hh:974
iter prepend_child(iter position)
Definition: tree.hh:865
compare_nodes(StrictWeakOrdering comp)
Definition: tree.hh:423
bool operator==(const sibling_iterator &) const 
Definition: tree.hh:2018
StrictWeakOrdering comp_
Definition: tree.hh:430
void set_parent_()
Definition: tree.hh:2600
pre_order_iterator & operator+=(unsigned int)
Definition: tree.hh:2172
iter move_after(iter target, iter source)
Move 'source' node (plus its children) to become the next sibling of 'target'. 
Definition: tree.hh:1346
tree< T, tree_node_allocator > & operator=(const tree< T, tree_node_allocator > &)
Definition: tree.hh:529
pre_order_iterator iterator
The default iterator types throughout the tree class. 
Definition: tree.hh:178
size_t size() const 
Count the total number of nodes. 
Definition: tree.hh:1634
iter next_at_same_depth(iter) const 
Return iterator to the next node at a given depth. 
Definition: tree.hh:793
iterator lowest_common_ancestor(const iterator_base &, const iterator_base &) const 
Definition: tree.hh:1860
tree_node * range_last() const 
Definition: tree.hh:2671
T * operator->() const 
Definition: tree.hh:1977
std::queue< tree_node * > traversal_queue
Definition: tree.hh:174
T & reference
Definition: tree.hh:96