COMPILATION LISTING OF SEGMENT mrds_rst_tree_successor Compiled by: Multics PL/I Compiler, Release 28e, of February 14, 1985 Compiled at: Honeywell Multics Op. - System M Compiled on: 04/18/85 1105.2 mst Thu Options: optimize map 1 /* *********************************************************** 2* * * 3* * * 4* * Copyright, (C) Honeywell Information Systems Inc., 1981 * 5* * * 6* * * 7* *********************************************************** */ 8 9 /* ****************************************************** 10* * * 11* * * 12* * Copyright (c) 1972 by Massachusetts Institute of * 13* * Technology and Honeywell Information Systems, Inc. * 14* * * 15* * * 16* ****************************************************** */ 17 18 mrds_rst_tree_successor: procedure (root_ptr, node_ptr, successor_ptr, successor_parent_ptr, success); 19 20 21 /* HISTORY: 22* 23* originally written by jim gray - - july 1978 24* 25**/ 26 27 /* DESCRIPTION: 28* threaded binary tree inorder successor retrieval routine 29* given a pointer to the current node in the tree 30* ( set node_ptr = root_ptr to get first tree element ) 31* and a pointer to the root of the tree 32* a pointer to it's inorder successor and that nodes parent 33* are returned with a success indication, or 34* when end of tree(no more successors) or empty tree is detected, 35* a failure indication is returned */ 36 37 /* PARAMETERS: 38* 39* root_ptr - - (input) pointer to root of desired tree 40* 41* node_ptr - - (input) pointer to current for which the successor is desired 42* 43* successor_ptr - - (output) pointer to resulting inorder successor of current node 44* 45* successor_parent_ptr - - (output) pointer to successor node direct tree parent 46* 47* success - - (output) bit value that is on when successor found, 48* and off when end of tree or empty tree is detected 49* 50**/ 51 52 53 54 /* no current node means no successor */ 55 56 if node_ptr = null () then 57 success = "0"b; 58 59 else do; 60 61 /* current node exists, if it's right link is a thread 62* it is either a pointer to the root meaning no more successors 63* or it points to the current node's inorder successor */ 64 65 successor_parent_ptr = node_ptr; 66 successor_ptr = node_ptr -> node.right.link; 67 68 if node_ptr -> node.right.thread then 69 70 if successor_ptr = root_ptr then 71 success = "0"b; 72 else success = "1"b; 73 74 else do; 75 76 /* current node's right link is not a thread, 77* go left from current node's right descendent until 78* a left thread is found and return it's owner 79* as the inorder successor */ 80 81 do while (^successor_ptr -> node.left.thread); 82 83 successor_parent_ptr = successor_ptr; 84 successor_ptr = successor_ptr -> node.left.link; 85 86 end; 87 88 /* if pointer is still to root, the dummy head node 89* left link was a thread indicating an empty tree */ 90 91 if successor_ptr = root_ptr then 92 success = "0"b; 93 else success = "1"b; 94 95 end; 96 97 98 end; 99 100 dcl null builtin; 101 102 1 1 /* BEGIN INCLUDE FILE mrds_rst_tree.incl.pl1 jeg 7/19/78 */ 1 2 1 3 /* common declarations for threaded binary tree routines 1 4* 1 5* The tree maintains an inorder list of it's keys. 1 6* this means that for a given node, any key in it's left subtree 1 7* is "less" than the given node's key and that any key in it's 1 8* right subtree is "greater" than the given node's key. 1 9* 1 10* Threads are maintained to allow fast and easy traversal of the tree. 1 11* threads occupy the position of null pointers of an straight binary tree, 1 12* thus they only occur in leaf nodes. 1 13* left threads point to that nodes inorder predecessor. 1 14* right threads point to that nodes inorder successor. 1 15* 1 16* note: root_ptr must be passed by reference 1 17* ( not by value ) so it can be changed . 1 18* Also, each parameter must be a different 1 19* variable. The same variable used for two 1 20* or more arguments when any of the tree 1 21* routines are called will produce errors */ 1 22 1 23 1 24 declare key char (32) aligned ; /* data key directing search */ 1 25 1 26 declare root_ptr ptr ; /* pointer to head of desired list */ 1 27 declare node_ptr ptr ; /* pointer to key node, when success */ 1 28 declare parent_ptr ptr ; /* pointer to direct parent of current node */ 1 29 declare data_ptr ptr ; /* pointer from tree node to data structure headed by node */ 1 30 declare successor_ptr ptr ; /* pointer to inorder successor of current node in tree */ 1 31 declare successor_parent_ptr ptr ; /* pointer to immediate tree parent of inorder successor node */ 1 32 declare predecessor_ptr ptr ; /* pointer to inorder predecessor of current node */ 1 33 declare predecessor_parent_ptr ptr ; /* pointer to direct parent of predecessor */ 1 34 declare area_ptr ptr ; /* pointer to based area for node allocation/freeing */ 1 35 1 36 declare work_area area based (area_ptr) ; /* area of storage for tree */ 1 37 1 38 declare success bit (1) ; /* on if operation successful */ 1 39 declare thread bit (1) aligned ; /* current thread indicator, on = thread, off = pointer */ 1 40 1 41 declare 1 node based (node_ptr) aligned, /* tree element */ 1 42 2 data ptr, /* data field link */ 1 43 2 key char (32), /* data key */ 1 44 2 right, /* right branch link */ 1 45 3 thread bit (1), /* indicates whether link is thread or pointer */ 1 46 3 link ptr, /* pointer to right descendent or thread to successor */ 1 47 2 left, /* left branch link */ 1 48 3 thread bit (1), /* indicates whether link is thread or pointer */ 1 49 3 link ptr, /* pointer to left descendent or thread to predecessor */ 1 50 2 pad bit (34) ; /* reserved for future flags */ 1 51 1 52 /* END INCLUDE FILE mrds_rst_tree.incl.pl1 */ 1 53 1 54 1 55 1 56 103 104 105 106 107 108 end; SOURCE FILES USED IN THIS COMPILATION. LINE NUMBER DATE MODIFIED NAME PATHNAME 0 04/18/85 0909.3 mrds_rst_tree_successor.pl1 >special_ldd>online>mrds.pbf-04/18/85>mrds_rst_tree_successor.pl1 103 1 10/14/83 1608.6 mrds_rst_tree.incl.pl1 >ldd>include>mrds_rst_tree.incl.pl1 NAMES DECLARED IN THIS COMPILATION. IDENTIFIER OFFSET LOC STORAGE CLASS DATA TYPE ATTRIBUTES AND REFERENCES (* indicates a set context) NAMES DECLARED BY DECLARE STATEMENT. left 16 based structure level 2 dcl 1-41 link 14 based pointer level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_successor" ref 66 link 20 based pointer level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_successor" ref 84 node based structure level 1 dcl 1-41 node_ptr parameter pointer dcl 1-27 ref 18 56 65 66 68 null builtin function dcl 100 ref 56 right 12 based structure level 2 dcl 1-41 root_ptr parameter pointer dcl 1-26 ref 18 68 91 success parameter bit(1) unaligned dcl 1-38 set ref 18 56* 68* 72* 91* 93* successor_parent_ptr parameter pointer dcl 1-31 set ref 18 65* 83* successor_ptr parameter pointer dcl 1-30 set ref 18 66* 68 81 83 84* 84 91 thread 16 based bit(1) level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_successor" ref 81 thread 12 based bit(1) level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_successor" ref 68 NAMES DECLARED BY DECLARE STATEMENT AND NEVER REFERENCED. area_ptr automatic pointer dcl 1-34 data_ptr automatic pointer dcl 1-29 key automatic char(32) dcl 1-24 parent_ptr automatic pointer dcl 1-28 predecessor_parent_ptr automatic pointer dcl 1-33 predecessor_ptr automatic pointer dcl 1-32 thread automatic bit(1) dcl 1-39 work_area based area(1024) dcl 1-36 NAME DECLARED BY EXPLICIT CONTEXT. mrds_rst_tree_successor 000011 constant entry external dcl 18 THERE WERE NO NAMES DECLARED BY CONTEXT OR IMPLICATION. STORAGE REQUIREMENTS FOR THIS PROGRAM. Object Text Link Symbol Defs Static Start 0 0 142 152 113 152 Length 342 113 10 153 27 0 BLOCK NAME STACK SIZE TYPE WHY NONQUICK/WHO SHARES STACK FRAME mrds_rst_tree_successor 64 external procedure is an external procedure. THE FOLLOWING EXTERNAL OPERATORS ARE USED BY THIS PROGRAM. return ext_entry NO EXTERNAL ENTRIES ARE CALLED BY THIS PROGRAM. NO EXTERNAL VARIABLES ARE USED BY THIS PROGRAM. LINE LOC LINE LOC LINE LOC LINE LOC LINE LOC LINE LOC LINE LOC 18 000004 56 000016 65 000030 66 000033 68 000037 72 000054 81 000061 83 000067 84 000070 86 000074 91 000075 93 000106 108 000112 ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group BULL including BULL HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell BULL Inc., Groupe BULL and BULL HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, BULL or BULL HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by BULL HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved