1*abe93798SAugustin Cavalier #include <search.h>
2*abe93798SAugustin Cavalier #include "tsearch.h"
3*abe93798SAugustin Cavalier
walk(const struct node * r,void (* action)(const void *,VISIT,int),int d)4*abe93798SAugustin Cavalier static void walk(const struct node *r, void (*action)(const void *, VISIT, int), int d)
5*abe93798SAugustin Cavalier {
6*abe93798SAugustin Cavalier if (!r)
7*abe93798SAugustin Cavalier return;
8*abe93798SAugustin Cavalier if (r->h == 1)
9*abe93798SAugustin Cavalier action(r, leaf, d);
10*abe93798SAugustin Cavalier else {
11*abe93798SAugustin Cavalier action(r, preorder, d);
12*abe93798SAugustin Cavalier walk(r->a[0], action, d+1);
13*abe93798SAugustin Cavalier action(r, postorder, d);
14*abe93798SAugustin Cavalier walk(r->a[1], action, d+1);
15*abe93798SAugustin Cavalier action(r, endorder, d);
16*abe93798SAugustin Cavalier }
17*abe93798SAugustin Cavalier }
18*abe93798SAugustin Cavalier
twalk(const void * root,void (* action)(const void *,VISIT,int))19*abe93798SAugustin Cavalier void twalk(const void *root, void (*action)(const void *, VISIT, int))
20*abe93798SAugustin Cavalier {
21*abe93798SAugustin Cavalier walk(root, action, 0);
22*abe93798SAugustin Cavalier }
23