Beispiel #1
0
//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>---: 
void mirror(tree_t &T,node_t n) {
  list< tree<int> > L;
  node_t c = n.lchild();
  if (c==T.end()) return;
  while (c!=T.end()) {
    printf("passing to list subtree rooted at %d\n",*c);
    L.insert(L.begin(),tree_t());
    tree_t &Q = *L.begin();
    T.splice(Q.begin(),c);
#if 0
    cout << "T: \n";
    T.lisp_print();
    cout << "\nQ: \n";
    Q.lisp_print();
    cout << endl;
#endif
    mirror(Q);
    c = n.lchild();
  }

  c = n.lchild();
  while (!L.empty()) {
    tree_t &Q = *L.begin();
    printf("passing to tree subtree rooted at %d\n",*Q.begin());
    c = T.splice(c,Q.begin());
    c++;
    L.erase(L.begin());
  }
}
Beispiel #2
0
void Insert_Node( tree_t &tree, node_t &node )
{
	tree_t::iterator ptr;

	ptr = tree.end();

	// insert smallest items at back
	for( int lcv = tree.size() - 1; lcv >= 0; lcv--, ptr-- ) {
		if( node.size <= tree[ lcv ].size ) break;
	}

	tree.insert( ptr, node );
}