| 5507 | } |
| 5508 | |
| 5509 | static void tree_walk(const struct node_s *n, int depth, |
| 5510 | void (*action)(const void *, const VISIT, const int)) |
| 5511 | { |
| 5512 | if (TREE_LEFT(n) == NULL && TREE_RIGHT(n) == NULL) |
| 5513 | action(n, leaf, depth); |
| 5514 | else |
| 5515 | { |
| 5516 | action(n, preorder, depth); |
| 5517 | if (TREE_LEFT(n) != NULL) |
| 5518 | tree_walk(TREE_LEFT(n), depth+1, action); |
| 5519 | action(n, postorder, depth); |
| 5520 | if (TREE_RIGHT(n) != NULL) |
| 5521 | tree_walk(TREE_RIGHT(n), depth+1, action); |
| 5522 | action(n, endorder, depth); |
| 5523 | } |
| 5524 | } |
| 5525 | static void twalk(const void *root, |
| 5526 | void (*action)(const void *, const VISIT, const int)) |
| 5527 | { |