1 /* BEGIN INCLUDE FILE mrds_rst_tree.incl.pl1 jeg 7/19/78 */ 2 3 /* common declarations for threaded binary tree routines 4 5 The tree maintains an inorder list of it's keys. 6 this means that for a given node, any key in it's left subtree 7 is "less" than the given node's key and that any key in it's 8 right subtree is "greater" than the given node's key. 9 10 Threads are maintained to allow fast and easy traversal of the tree. 11 threads occupy the position of null pointers of an straight binary tree, 12 thus they only occur in leaf nodes. 13 left threads point to that nodes inorder predecessor. 14 right threads point to that nodes inorder successor. 15 16 note: root_ptr must be passed by reference 17 ( not by value ) so it can be changed . 18 Also, each parameter must be a different 19 variable. The same variable used for two 20 or more arguments when any of the tree 21 routines are called will produce errors */ 22 23 24 declare key char (32) aligned ; /* data key directing search */ 25 26 declare root_ptr ptr ; /* pointer to head of desired list */ 27 declare node_ptr ptr ; /* pointer to key node, when success */ 28 declare parent_ptr ptr ; /* pointer to direct parent of current node */ 29 declare data_ptr ptr ; /* pointer from tree node to data structure headed by node */ 30 declare successor_ptr ptr ; /* pointer to inorder successor of current node in tree */ 31 declare successor_parent_ptr ptr ; /* pointer to immediate tree parent of inorder successor node */ 32 declare predecessor_ptr ptr ; /* pointer to inorder predecessor of current node */ 33 declare predecessor_parent_ptr ptr ; /* pointer to direct parent of predecessor */ 34 declare area_ptr ptr ; /* pointer to based area for node allocation/freeing */ 35 36 declare work_area area based (area_ptr) ; /* area of storage for tree */ 37 38 declare success bit (1) ; /* on if operation successful */ 39 declare thread bit (1) aligned ; /* current thread indicator, on = thread, off = pointer */ 40 41 declare 1 node based (node_ptr) aligned, /* tree element */ 42 2 data ptr, /* data field link */ 43 2 key char (32), /* data key */ 44 2 right, /* right branch link */ 45 3 thread bit (1), /* indicates whether link is thread or pointer */ 46 3 link ptr, /* pointer to right descendent or thread to successor */ 47 2 left, /* left branch link */ 48 3 thread bit (1), /* indicates whether link is thread or pointer */ 49 3 link ptr, /* pointer to left descendent or thread to predecessor */ 50 2 pad bit (34) ; /* reserved for future flags */ 51 52 /* END INCLUDE FILE mrds_rst_tree.incl.pl1 */ 53 54 55 56