COMPILATION LISTING OF SEGMENT mrds_rst_tree_predecessor 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.1 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_predecessor: procedure (root_ptr, node_ptr, predecessor_ptr, predecessor_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 predecessor retrieval routine 29* given a pointer to the current node in the tree 30* ( set node_ptr = root_ptr to get last tree element ) 31* and a pointer to the root of the tree 32* a pointer to it's inorder predecessor and that nodes parent 33* are returned with a success indication, or 34* when end of tree(no more predecessors) 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 predecessor is desired 42* 43* predecessor_ptr - - (output) pointer to resulting inorder predecessor of current node 44* 45* predecessor_parent_ptr - - (output) pointer to predecessor node direct tree parent 46* 47* success - - (output) bit value that is on when predecessor found, 48* and off when end of tree or empty tree is detected 49* 50**/ 51 52 53 54 /* no current node means no predecessor */ 55 56 if node_ptr = null () then 57 success = "0"b; 58 59 else do; 60 61 /* current node exists, if it's left link is a thread 62* it is either a pointer to the root meaning no more predecessors 63* (or empty tree when node_ptr was root_ptr) 64* or it points to the current node's inorder predecessor */ 65 66 predecessor_parent_ptr = node_ptr; 67 predecessor_ptr = node_ptr -> node.left.link; 68 69 if node_ptr -> node.left.thread then 70 71 if predecessor_ptr = root_ptr then 72 success = "0"b; 73 else success = "1"b; 74 75 else do; 76 77 /* current node's left link is not a thread, 78* go left from current node's left descendent until 79* a right thread is found and return it's owner 80* as the inorder predecessor */ 81 82 success = "1"b; 83 84 do while (^predecessor_ptr -> node.right.thread); 85 86 predecessor_parent_ptr = predecessor_ptr; 87 predecessor_ptr = predecessor_ptr -> node.right.link; 88 89 end; 90 91 end; 92 93 94 end; 95 96 dcl null builtin; 97 98 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 99 100 101 102 103 104 end; SOURCE FILES USED IN THIS COMPILATION. LINE NUMBER DATE MODIFIED NAME PATHNAME 0 04/18/85 0909.3 mrds_rst_tree_predecessor.pl1 >special_ldd>online>mrds.pbf-04/18/85>mrds_rst_tree_predecessor.pl1 99 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_predecessor" ref 87 link 20 based pointer level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_predecessor" ref 67 node based structure level 1 dcl 1-41 node_ptr parameter pointer dcl 1-27 ref 18 56 66 67 69 null builtin function dcl 96 ref 56 predecessor_parent_ptr parameter pointer dcl 1-33 set ref 18 66* 86* predecessor_ptr parameter pointer dcl 1-32 set ref 18 67* 69 84 86 87* 87 right 12 based structure level 2 dcl 1-41 root_ptr parameter pointer dcl 1-26 ref 18 69 success parameter bit(1) unaligned dcl 1-38 set ref 18 56* 69* 73* 82* thread 16 based bit(1) level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_predecessor" ref 69 thread 12 based bit(1) level 3 in structure "node" dcl 1-41 in procedure "mrds_rst_tree_predecessor" ref 84 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 successor_parent_ptr automatic pointer dcl 1-31 successor_ptr automatic pointer dcl 1-30 thread automatic bit(1) dcl 1-39 work_area based area(1024) dcl 1-36 NAME DECLARED BY EXPLICIT CONTEXT. mrds_rst_tree_predecessor 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 132 142 102 142 Length 332 102 10 154 30 0 BLOCK NAME STACK SIZE TYPE WHY NONQUICK/WHO SHARES STACK FRAME mrds_rst_tree_predecessor 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 66 000030 67 000033 69 000037 73 000054 82 000061 84 000065 86 000073 87 000074 89 000100 104 000101 ----------------------------------------------------------- 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