void process_all( map_t tree, struct avl_node *p, process_each_func f, void * param ) { if( tree->ret_code ) return; if( p->avl_link[0] ) process_all( tree, p->avl_link[0], f ,param ); tree->ret_code |= f( param, p->key, p->val); if( p->avl_link[1] ) process_all( tree, p->avl_link[1], f ,param ); }
int map_for_each( map_t tree, process_each_func f, void * param) { tree->ret_code = 0; if( tree->avl_root ) process_all( tree, tree->avl_root, f, param); return tree->ret_code; }
main () { int edge[MAX_PIECES], i, e = EMPTY; #ifdef DEBUG if (!(Debug_Fp = fopen ("debug.out", "w"))) quit(-1,"Couldn't open debug.out for writing\n"); #endif for (i = 0; i < 10; i++) edge[i] = EMPTY; compute_edge (edge, &Edge_Table[e][e][e][e][e][e][e][e][e][e]); process_all (); fprintf (stderr, "Average iterations = %f, Maximum = %d\n", (double) Total_Iters/Converged, Max_Num_Times); print_result (Edge_Table); return 0; }