diff options
Diffstat (limited to 'treeutil.h')
| -rw-r--r-- | treeutil.h | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/treeutil.h b/treeutil.h deleted file mode 100644 index 76627c0..0000000 --- a/treeutil.h +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | // aux display and verification routines, helpful but not essential | ||
| 2 | struct trunk { | ||
| 3 | struct trunk *prev; | ||
| 4 | const char * str; | ||
| 5 | }; | ||
| 6 | |||
| 7 | static void | ||
| 8 | show_trunks(struct trunk *p) | ||
| 9 | { | ||
| 10 | if ( !p ) | ||
| 11 | return; | ||
| 12 | show_trunks(p->prev); | ||
| 13 | printf("%s", p->str); | ||
| 14 | } | ||
| 15 | |||
| 16 | // this is very haphazzard | ||
| 17 | static void | ||
| 18 | show_tree(struct tree_node *root, struct trunk *prev, int is_left) | ||
| 19 | { | ||
| 20 | if ( root == NULL ) | ||
| 21 | return; | ||
| 22 | |||
| 23 | struct trunk this_disp = { prev, " " }; | ||
| 24 | const char * prev_str = this_disp.str; | ||
| 25 | show_tree(root->right, &this_disp, 1); | ||
| 26 | |||
| 27 | if ( !prev ) | ||
| 28 | this_disp.str = "---"; | ||
| 29 | else if ( is_left ) { | ||
| 30 | this_disp.str = ".--"; | ||
| 31 | prev_str = " |"; | ||
| 32 | } | ||
| 33 | else { | ||
| 34 | this_disp.str = "`--"; | ||
| 35 | prev->str = prev_str; | ||
| 36 | } | ||
| 37 | |||
| 38 | show_trunks(&this_disp); | ||
| 39 | if ( root->key >= 'A' && root->key <= 'Z' ) | ||
| 40 | printf("%c\n", root->key); | ||
| 41 | else | ||
| 42 | printf("%d\n", root->key); | ||
| 43 | |||
| 44 | if ( prev ) | ||
| 45 | prev->str = prev_str; | ||
| 46 | this_disp.str = " |"; | ||
| 47 | |||
| 48 | show_tree(root->left, &this_disp, 0); | ||
| 49 | if ( !prev ) | ||
| 50 | puts(""); | ||
| 51 | } | ||
