TABLE.LST 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. Listing:
  2. 1 (* ==================================================== *)
  3. 2 (* Copyright (C) 1990-1992 Clarion Software Corporation *)
  4. 3 (* ==================================================== *)
  5. 4
  6. 5 IMPLEMENTATION MODULE Table;
  7. 6
  8. 7 IMPORT Lib;
  9. 8 FROM Storage IMPORT ALLOCATE, DEALLOCATE;
  10. 9
  11. 10
  12. 11 CLASS IMPLEMENTATION Element;
  13. ***** ^ undeclared identifier
  14. 12
  15. 13 VIRTUAL PROCEDURE Compare( p : ElementPtr ) : INTEGER;
  16. ***** ^ undeclared identifier
  17. 14 (* It is an error not to supply an implementation of this
  18. 15 method. The client MUST supply a method to compare
  19. 16 'THIS' with 'p'.
  20. 17 *)
  21. 18 BEGIN
  22. 19 Lib.FatalError(' implemeted by client ');
  23. ***** ^ not supported yet
  24. ***** ^ not supported yet
  25. ***** ^ not supported yet
  26. 20 RETURN 0;
  27. 21 END Compare;
  28. ***** ^ not supported yet
  29. 22
  30. 23 BEGIN
  31. 24 END Element ;
  32. ***** ^ not supported yet
  33. 25
  34. 26 CLASS GenElem (Element) ;
  35. ***** ^ undeclared identifier
  36. 27 GenericData : CHAR;
  37. 28 END GenElem;
  38. ***** ^ not supported yet
  39. 29
  40. 30 CLASS IMPLEMENTATION GenElem;
  41. 31 BEGIN
  42. 32 END GenElem;
  43. ***** ^ not supported yet
  44. 33
  45. 34 TYPE
  46. 35 GenElemPtr = POINTER TO GenElem;
  47. ***** ^ not supported yet
  48. 36 (* The above definitions are a skeleton for all the
  49. 37 implementation of the 'Element' CLASS. This enables
  50. 38 the 'TABLE' class to successfully copy any client
  51. 39 implementation of 'Element'
  52. 40 *)
  53. 41
  54. 42
  55. 43 CLASS IMPLEMENTATION TABLE;
  56. ***** ^ undeclared identifier
  57. 44
  58. 45 PROCEDURE Insert( VAR x : Element );
  59. ***** ^ undeclared identifier
  60. 46 (* Insert a new element 'x' in 'THIS' table *)
  61. 47
  62. 48 PROCEDURE Search( VAR p : ElementPtr; VAR h : BOOLEAN);
  63. ***** ^ undeclared identifier
  64. 49 (* Searches a tree 'p' for the element 'x'. If it is found
  65. 50 then the new value replaces the old. If 'x' is not
  66. 51 in the tree, then 'x' becomes a new leaf of the tree.
  67. 52 *)
  68. 53 VAR
  69. 54 p1 : ElementPtr;
  70. ***** ^ undeclared identifier
  71. 55 p2 : ElementPtr;
  72. ***** ^ undeclared identifier
  73. 56
  74. 57 BEGIN
  75. 58 IF (p = NIL) THEN (* Create new leaf *)
  76. ***** ^ not supported yet
  77. 59 ALLOCATE(p,SIZE(x));
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. ***** ^ undeclared identifier
  81. ***** ^ not supported yet
  82. 60 Lib.Move(ADR(x),p,SIZE(x));
  83. ***** ^ not supported yet
  84. ***** ^ not supported yet
  85. ***** ^ undeclared identifier
  86. ***** ^ not supported yet
  87. ***** ^ not supported yet
  88. ***** ^ undeclared identifier
  89. ***** ^ not supported yet
  90. 61 p^.Bal := 0;
  91. ***** ^ not supported yet
  92. ***** ^ not supported yet
  93. 62 p^.Left := NIL;
  94. ***** ^ not supported yet
  95. ***** ^ not supported yet
  96. 63 p^.Right := NIL;
  97. ***** ^ not supported yet
  98. ***** ^ not supported yet
  99. 64 h := TRUE; (* Tree requires balancing *)
  100. 65 ELSE
  101. 66 IF (x.Compare(p) < 0) THEN (* 'THIS' is < 'p' *)
  102. ***** ^ not supported yet
  103. ***** ^ not supported yet
  104. ***** ^ not supported yet
  105. 67 (* Search the 'Left' branch of 'p' recursively
  106. 68 until 'x' is either found or created.
  107. 69 *)
  108. 70 Search(p^.Left,h);
  109. ***** ^ not supported yet
  110. ***** ^ not supported yet
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. 71 IF h THEN (* i.e. requires balancing *)
  114. 72 CASE p^.Bal OF
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. 73 | 1 :
  118. 74 p^.Bal := 0;
  119. ***** ^ not supported yet
  120. ***** ^ not supported yet
  121. 75 h := FALSE;
  122. 76 | 0 :
  123. 77 p^.Bal := -1;
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 78 | -1 :
  127. 79 p1 := p^.Left;
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. ***** ^ not supported yet
  131. 80 IF (p1^.Bal = -1) THEN
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. 81 p^.Left := p1^.Right;
  135. ***** ^ not supported yet
  136. ***** ^ not supported yet
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. 82 p1^.Right := p;
  140. ***** ^ not supported yet
  141. ***** ^ not supported yet
  142. ***** ^ not supported yet
  143. 83 p^.Bal := 0;
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. 84 p := p1;
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. 85 ELSE
  150. 86 p2 := p1^.Right;
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. ***** ^ not supported yet
  154. 87 p1^.Right := p2^.Left;
  155. ***** ^ not supported yet
  156. ***** ^ not supported yet
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. 88 p2^.Left := p1;
  160. ***** ^ not supported yet
  161. ***** ^ not supported yet
  162. ***** ^ not supported yet
  163. 89 p^.Left := p2^.Right;
  164. ***** ^ not supported yet
  165. ***** ^ not supported yet
  166. ***** ^ not supported yet
  167. ***** ^ not supported yet
  168. 90 p2^.Right := p;
  169. ***** ^ not supported yet
  170. ***** ^ not supported yet
  171. ***** ^ not supported yet
  172. 91 IF (p2^.Bal = -1) THEN
  173. ***** ^ not supported yet
  174. ***** ^ not supported yet
  175. 92 p^.Bal := 1;
  176. ***** ^ not supported yet
  177. ***** ^ not supported yet
  178. 93 ELSE
  179. 94 p^.Bal := 0;
  180. ***** ^ not supported yet
  181. ***** ^ not supported yet
  182. 95 END;
  183. 96 IF (p2^.Bal = 1) THEN
  184. ***** ^ not supported yet
  185. ***** ^ not supported yet
  186. 97 p1^.Bal := -1;
  187. ***** ^ not supported yet
  188. ***** ^ not supported yet
  189. 98 ELSE
  190. 99 p1^.Bal := 0;
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. 100 END;
  194. 101 p := p2;
  195. ***** ^ not supported yet
  196. ***** ^ not supported yet
  197. 102 END;
  198. 103 p^.Bal := 0;
  199. ***** ^ not supported yet
  200. ***** ^ not supported yet
  201. 104 h := FALSE; (* Balancing done *)
  202. 105 END (* CASE *);
  203. 106 END (* of balancing 'Left' sub-tree *);
  204. 107 ELSIF (x.Compare(p) > 0) THEN (* 'THIS' > 'p' *)
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. 108 (* Search the 'Right' branch of 'p' recursively
  209. 109 until 'x' is either found or created.
  210. 110 *)
  211. 111 Search( p^.Right,h);
  212. ***** ^ not supported yet
  213. ***** ^ not supported yet
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. 112 IF h THEN (* i.e. tree needs balancing *)
  217. 113 CASE p^.Bal OF
  218. ***** ^ not supported yet
  219. ***** ^ not supported yet
  220. 114 | -1 :
  221. 115 p^.Bal := 0;
  222. ***** ^ not supported yet
  223. ***** ^ not supported yet
  224. 116 h := FALSE;
  225. 117 | 0 :
  226. 118 p^.Bal := 1;
  227. ***** ^ not supported yet
  228. ***** ^ not supported yet
  229. 119 | 1 :
  230. 120 p1 := p^.Right;
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. 121 IF (p1^.Bal = 1) THEN
  235. ***** ^ not supported yet
  236. ***** ^ not supported yet
  237. 122 p^.Right := p1^.Left;
  238. ***** ^ not supported yet
  239. ***** ^ not supported yet
  240. ***** ^ not supported yet
  241. ***** ^ not supported yet
  242. 123 p1^.Left := p;
  243. ***** ^ not supported yet
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. 124 p^.Bal := 0;
  247. ***** ^ not supported yet
  248. ***** ^ not supported yet
  249. 125 p := p1;
  250. ***** ^ not supported yet
  251. ***** ^ not supported yet
  252. 126 ELSE
  253. 127 p2 := p1^.Left;
  254. ***** ^ not supported yet
  255. ***** ^ not supported yet
  256. ***** ^ not supported yet
  257. 128 p1^.Left := p2^.Right;
  258. ***** ^ not supported yet
  259. ***** ^ not supported yet
  260. ***** ^ not supported yet
  261. ***** ^ not supported yet
  262. 129 p2^.Right := p1;
  263. ***** ^ not supported yet
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. 130 p^.Right := p2^.Left;
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. 131 p2^.Left := p;
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. ***** ^ not supported yet
  275. 132 IF (p2^.Bal = 1) THEN
  276. ***** ^ not supported yet
  277. ***** ^ not supported yet
  278. 133 p^.Bal := -1;
  279. ***** ^ not supported yet
  280. ***** ^ not supported yet
  281. 134 ELSE
  282. 135 p^.Bal := 0;
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. 136 END;
  286. 137 IF (p2^.Bal = -1) THEN
  287. ***** ^ not supported yet
  288. ***** ^ not supported yet
  289. 138 p1^.Bal := 1;
  290. ***** ^ not supported yet
  291. ***** ^ not supported yet
  292. 139 ELSE
  293. 140 p1^.Bal := 0;
  294. ***** ^ not supported yet
  295. ***** ^ not supported yet
  296. 141 END;
  297. 142 p := p2;
  298. ***** ^ not supported yet
  299. ***** ^ not supported yet
  300. 143 END;
  301. 144 p^.Bal := 0;
  302. ***** ^ not supported yet
  303. ***** ^ not supported yet
  304. 145 h := FALSE; (* Tree balanced *)
  305. 146 END (* CASE *);
  306. 147 END (* Balancing 'Right' sub-tree *);
  307. 148 ELSE (* 'THIS' and 'p' are the same *)
  308. 149 h := FALSE;
  309. 150 Lib.Move(ADR(GenElemPtr(ADR(x))^.GenericData),
  310. ***** ^ not supported yet
  311. ***** ^ not supported yet
  312. ***** ^ undeclared identifier
  313. ***** ^ undeclared identifier
  314. ***** ^ not supported yet
  315. ***** ^ not supported yet
  316. 151 ADR(GenElemPtr(p)^.GenericData),
  317. ***** ^ undeclared identifier
  318. ***** ^ not supported yet
  319. ***** ^ not supported yet
  320. 152 SIZE(x)-VSIZE(Element.Bal));
  321. ***** ^ undeclared identifier
  322. ***** ^ not supported yet
  323. ***** ^ undeclared identifier
  324. ***** ^ undeclared identifier
  325. ***** ^ not supported yet
  326. 153 END (* Possible comaprison results *);
  327. 154 END;
  328. 155 END Search;
  329. ***** ^ not supported yet
  330. 156
  331. 157 VAR
  332. 158 h : BOOLEAN;
  333. 159
  334. 160 BEGIN
  335. 161 IF (Root # NIL) AND (ADR(Root^.Compare) # ADR(x.Compare)) THEN
  336. ***** ^ undeclared identifier
  337. ***** ^ undeclared identifier
  338. ***** ^ undeclared identifier
  339. ***** ^ not supported yet
  340. ***** ^ undeclared identifier
  341. ***** ^ not supported yet
  342. ***** ^ not supported yet
  343. 162 (* All table elements must be homogeneous; i.e. they must be of
  344. 163 the same CLASS
  345. 164 *)
  346. 165 Lib.FatalError('object not compatible with table');
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. ***** ^ not supported yet
  350. 166 END;
  351. 167 Search(Root,h);
  352. ***** ^ not supported yet
  353. ***** ^ undeclared identifier
  354. ***** ^ not supported yet
  355. 168 END Insert;
  356. ***** ^ not supported yet
  357. 169
  358. 170 PROCEDURE Find( VAR x : Element ) : BOOLEAN;
  359. ***** ^ undeclared identifier
  360. 171 (* Search for 'x' in 'THIS' tree; if 'x' is found in
  361. 172 'THIS' tree then the function returns 'TRUE' and 'x'
  362. 173 is set to the mathing element. Otherwise the
  363. 174 method returns 'FALSE'.
  364. 175 *)
  365. 176
  366. 177 PROCEDURE _Find( r : ElementPtr ) : ElementPtr;
  367. ***** ^ undeclared identifier
  368. ***** ^ undeclared identifier
  369. 178 (* Implements the search algorithm *)
  370. 179 BEGIN
  371. 180 LOOP
  372. 181 IF (r = NIL) THEN (* No match *)
  373. ***** ^ not supported yet
  374. 182 RETURN r;
  375. ***** ^ not supported yet
  376. 183 ELSIF (x.Compare(r) < 0) THEN (* 'THIS' < r *)
  377. ***** ^ not supported yet
  378. ***** ^ not supported yet
  379. ***** ^ not supported yet
  380. 184 r := r^.Left;
  381. ***** ^ not supported yet
  382. ***** ^ not supported yet
  383. ***** ^ not supported yet
  384. 185 ELSIF (x.Compare(r) > 0) THEN (* 'THIS' > r *)
  385. ***** ^ not supported yet
  386. ***** ^ not supported yet
  387. ***** ^ not supported yet
  388. 186 r := r^.Right;
  389. ***** ^ not supported yet
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. 187 ELSE (* FOUND IT! *)
  393. 188 RETURN r;
  394. ***** ^ not supported yet
  395. 189 END;
  396. 190 END (* LOOP *);
  397. 191 END _Find;
  398. ***** ^ not supported yet
  399. 192
  400. 193 VAR
  401. 194 p : ElementPtr;
  402. ***** ^ undeclared identifier
  403. 195
  404. 196 BEGIN
  405. 197 p := _Find(Root);
  406. ***** ^ not supported yet
  407. ***** ^ not supported yet
  408. ***** ^ undeclared identifier
  409. 198 IF (p # NIL) THEN (* Element Located *)
  410. ***** ^ not supported yet
  411. 199 Lib.Move(p,ADR(x),SIZE(x));
  412. ***** ^ not supported yet
  413. ***** ^ not supported yet
  414. ***** ^ not supported yet
  415. ***** ^ undeclared identifier
  416. ***** ^ not supported yet
  417. ***** ^ undeclared identifier
  418. ***** ^ not supported yet
  419. 200 RETURN TRUE;
  420. 201 ELSE
  421. 202 RETURN FALSE;
  422. 203 END;
  423. 204 END Find;
  424. ***** ^ not supported yet
  425. 205
  426. 206 PROCEDURE Delete( VAR x : Element );
  427. ***** ^ undeclared identifier
  428. 207 (* Locate the element 'x' in 'THIS' tree and delete it *)
  429. 208 VAR
  430. 209 q : ElementPtr;
  431. ***** ^ undeclared identifier
  432. 210
  433. 211 PROCEDURE r_Balance( VAR p : ElementPtr; VAR h : BOOLEAN);
  434. ***** ^ undeclared identifier
  435. 212 (* Blance a right sub-tree *)
  436. 213 VAR
  437. 214 p1 : ElementPtr;
  438. ***** ^ undeclared identifier
  439. 215 p2 : ElementPtr;
  440. ***** ^ undeclared identifier
  441. 216 b1 : BalanceFlag;
  442. ***** ^ undeclared identifier
  443. 217 b2 : BalanceFlag;
  444. ***** ^ undeclared identifier
  445. 218 BEGIN
  446. 219 CASE p^.Bal OF
  447. ***** ^ not supported yet
  448. ***** ^ not supported yet
  449. 220 | -1 :
  450. 221 p^.Bal := 0;
  451. ***** ^ not supported yet
  452. ***** ^ not supported yet
  453. 222 | 0 :
  454. 223 p^.Bal := 1;
  455. ***** ^ not supported yet
  456. ***** ^ not supported yet
  457. 224 h := FALSE;
  458. 225 | 1 :
  459. 226 p1 := p^.Right;
  460. ***** ^ not supported yet
  461. ***** ^ not supported yet
  462. ***** ^ not supported yet
  463. 227 b1 := p1^.Bal;
  464. ***** ^ not supported yet
  465. ***** ^ not supported yet
  466. ***** ^ not supported yet
  467. 228 IF (b1 >= 0) THEN
  468. ***** ^ not supported yet
  469. 229 p^.Right := p1^.Left;
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. ***** ^ not supported yet
  473. ***** ^ not supported yet
  474. 230 p1^.Left := p;
  475. ***** ^ not supported yet
  476. ***** ^ not supported yet
  477. ***** ^ not supported yet
  478. 231 IF (b1 = 0) THEN
  479. ***** ^ not supported yet
  480. 232 p^.Bal := 1;
  481. ***** ^ not supported yet
  482. ***** ^ not supported yet
  483. 233 p1^.Bal := -1;
  484. ***** ^ not supported yet
  485. ***** ^ not supported yet
  486. 234 h := FALSE
  487. 235 ELSE
  488. 236 p^.Bal := 0;
  489. ***** ^ not supported yet
  490. ***** ^ not supported yet
  491. 237 p1^.Bal := 0;
  492. ***** ^ not supported yet
  493. ***** ^ not supported yet
  494. 238 END;
  495. 239 p := p1;
  496. ***** ^ not supported yet
  497. ***** ^ not supported yet
  498. 240 ELSE
  499. 241 p2 := p1^.Left;
  500. ***** ^ not supported yet
  501. ***** ^ not supported yet
  502. ***** ^ not supported yet
  503. 242 b2 := p2^.Bal;
  504. ***** ^ not supported yet
  505. ***** ^ not supported yet
  506. ***** ^ not supported yet
  507. 243 p1^.Left := p2^.Right;
  508. ***** ^ not supported yet
  509. ***** ^ not supported yet
  510. ***** ^ not supported yet
  511. ***** ^ not supported yet
  512. 244 p2^.Right := p1;
  513. ***** ^ not supported yet
  514. ***** ^ not supported yet
  515. ***** ^ not supported yet
  516. 245 p^.Right := p2^.Left;
  517. ***** ^ not supported yet
  518. ***** ^ not supported yet
  519. ***** ^ not supported yet
  520. ***** ^ not supported yet
  521. 246 p2^.Left := p;
  522. ***** ^ not supported yet
  523. ***** ^ not supported yet
  524. ***** ^ not supported yet
  525. 247 IF (b2 = 1) THEN
  526. ***** ^ not supported yet
  527. 248 p^.Bal := -1;
  528. ***** ^ not supported yet
  529. ***** ^ not supported yet
  530. 249 ELSE
  531. 250 p^.Bal := 0;
  532. ***** ^ not supported yet
  533. ***** ^ not supported yet
  534. 251 END;
  535. 252 IF (b2 = -1) THEN
  536. ***** ^ not supported yet
  537. 253 p1^.Bal := 1;
  538. ***** ^ not supported yet
  539. ***** ^ not supported yet
  540. 254 ELSE
  541. 255 p1^.Bal := 0;
  542. ***** ^ not supported yet
  543. ***** ^ not supported yet
  544. 256 END;
  545. 257 p := p2;
  546. ***** ^ not supported yet
  547. ***** ^ not supported yet
  548. 258 p2^.Bal := 0;
  549. ***** ^ not supported yet
  550. ***** ^ not supported yet
  551. 259 END;
  552. 260 END (* CASE *);
  553. 261 END r_Balance;
  554. ***** ^ not supported yet
  555. 262
  556. 263 PROCEDURE l_Balance( VAR p : ElementPtr; VAR h : BOOLEAN);
  557. ***** ^ undeclared identifier
  558. 264 (* Balance a left sub-tree *)
  559. 265 VAR
  560. 266 p1 : ElementPtr;
  561. ***** ^ undeclared identifier
  562. 267 p2 : ElementPtr;
  563. ***** ^ undeclared identifier
  564. 268 b1 : BalanceFlag;
  565. ***** ^ undeclared identifier
  566. 269 b2 : BalanceFlag;
  567. ***** ^ undeclared identifier
  568. 270 BEGIN
  569. 271 CASE p^.Bal OF
  570. ***** ^ not supported yet
  571. ***** ^ not supported yet
  572. 272 | 1 :
  573. 273 p^.Bal := 0;
  574. ***** ^ not supported yet
  575. ***** ^ not supported yet
  576. 274 | 0 :
  577. 275 p^.Bal := -1;
  578. ***** ^ not supported yet
  579. ***** ^ not supported yet
  580. 276 h := FALSE;
  581. 277 | -1 :
  582. 278 p1 := p^.Left;
  583. ***** ^ not supported yet
  584. ***** ^ not supported yet
  585. ***** ^ not supported yet
  586. 279 b1 := p1^.Bal;
  587. ***** ^ not supported yet
  588. ***** ^ not supported yet
  589. ***** ^ not supported yet
  590. 280 IF (b1 <= 0) THEN
  591. ***** ^ not supported yet
  592. 281 p^.Left := p1^.Right;
  593. ***** ^ not supported yet
  594. ***** ^ not supported yet
  595. ***** ^ not supported yet
  596. ***** ^ not supported yet
  597. 282 p1^.Right := p;
  598. ***** ^ not supported yet
  599. ***** ^ not supported yet
  600. ***** ^ not supported yet
  601. 283 IF (b1 = 0) THEN
  602. ***** ^ not supported yet
  603. 284 p^.Bal := -1;
  604. ***** ^ not supported yet
  605. ***** ^ not supported yet
  606. 285 p1^.Bal := 1;
  607. ***** ^ not supported yet
  608. ***** ^ not supported yet
  609. 286 h := FALSE
  610. 287 ELSE
  611. 288 p^.Bal := 0;
  612. ***** ^ not supported yet
  613. ***** ^ not supported yet
  614. 289 p1^.Bal := 0;
  615. ***** ^ not supported yet
  616. ***** ^ not supported yet
  617. 290 END;
  618. 291 p := p1;
  619. ***** ^ not supported yet
  620. ***** ^ not supported yet
  621. 292 ELSE
  622. 293 p2 := p1^.Right;
  623. ***** ^ not supported yet
  624. ***** ^ not supported yet
  625. ***** ^ not supported yet
  626. 294 b2 := p2^.Bal;
  627. ***** ^ not supported yet
  628. ***** ^ not supported yet
  629. ***** ^ not supported yet
  630. 295 p1^.Right := p2^.Left;
  631. ***** ^ not supported yet
  632. ***** ^ not supported yet
  633. ***** ^ not supported yet
  634. ***** ^ not supported yet
  635. 296 p2^.Left := p1;
  636. ***** ^ not supported yet
  637. ***** ^ not supported yet
  638. ***** ^ not supported yet
  639. 297 p^.Left := p2^.Right;
  640. ***** ^ not supported yet
  641. ***** ^ not supported yet
  642. ***** ^ not supported yet
  643. ***** ^ not supported yet
  644. 298 p2^.Right := p;
  645. ***** ^ not supported yet
  646. ***** ^ not supported yet
  647. ***** ^ not supported yet
  648. 299 IF (b2 = -1) THEN
  649. ***** ^ not supported yet
  650. 300 p^.Bal := 1;
  651. ***** ^ not supported yet
  652. ***** ^ not supported yet
  653. 301 ELSE
  654. 302 p^.Bal := 0;
  655. ***** ^ not supported yet
  656. ***** ^ not supported yet
  657. 303 END;
  658. 304 IF (b2 = 1) THEN
  659. ***** ^ not supported yet
  660. 305 p1^.Bal := -1;
  661. ***** ^ not supported yet
  662. ***** ^ not supported yet
  663. 306 ELSE
  664. 307 p1^.Bal := 0;
  665. ***** ^ not supported yet
  666. ***** ^ not supported yet
  667. 308 END;
  668. 309 p := p2;
  669. ***** ^ not supported yet
  670. ***** ^ not supported yet
  671. 310 p2^.Bal := 0;
  672. ***** ^ not supported yet
  673. ***** ^ not supported yet
  674. 311 END;
  675. 312 END (* CASE *);
  676. 313 END l_Balance;
  677. ***** ^ not supported yet
  678. 314
  679. 315 PROCEDURE DeleteLeaf( VAR r : ElementPtr; VAR h : BOOLEAN );
  680. ***** ^ undeclared identifier
  681. 316 (* Recursively search for extreme right-hand node of
  682. 317 the sub-tree 'r' and move data into 'q'
  683. 318 *)
  684. 319 BEGIN
  685. 320 IF (r^.Right # NIL) THEN
  686. ***** ^ not supported yet
  687. ***** ^ not supported yet
  688. 321 DeleteLeaf(r^.Right,h);
  689. ***** ^ not supported yet
  690. ***** ^ not supported yet
  691. ***** ^ not supported yet
  692. ***** ^ not supported yet
  693. 322 IF h THEN
  694. 323 l_Balance(r,h);
  695. ***** ^ not supported yet
  696. ***** ^ not supported yet
  697. ***** ^ not supported yet
  698. 324 END;
  699. 325 ELSE
  700. 326 Lib.Move(ADR(GenElemPtr(r)^.GenericData),
  701. ***** ^ not supported yet
  702. ***** ^ not supported yet
  703. ***** ^ undeclared identifier
  704. ***** ^ not supported yet
  705. ***** ^ not supported yet
  706. 327 ADR(GenElemPtr(q)^.GenericData),
  707. ***** ^ undeclared identifier
  708. ***** ^ not supported yet
  709. ***** ^ not supported yet
  710. 328 SIZE(x)-VSIZE(Element.Bal));
  711. ***** ^ undeclared identifier
  712. ***** ^ not supported yet
  713. ***** ^ undeclared identifier
  714. ***** ^ undeclared identifier
  715. ***** ^ not supported yet
  716. 329 q := r;
  717. ***** ^ not supported yet
  718. ***** ^ not supported yet
  719. 330 r := r^.Left;
  720. ***** ^ not supported yet
  721. ***** ^ not supported yet
  722. ***** ^ not supported yet
  723. 331 h := TRUE;
  724. 332 END;
  725. 333 END DeleteLeaf;
  726. ***** ^ not supported yet
  727. 334
  728. 335 PROCEDURE _Delete( VAR p : ElementPtr; VAR h : BOOLEAN );
  729. ***** ^ undeclared identifier
  730. 336 (* Main recursive deletion procedure *)
  731. 337 BEGIN
  732. 338 IF (p = NIL) THEN (* Not found *)
  733. ***** ^ not supported yet
  734. 339 h := FALSE;
  735. 340 ELSIF (x.Compare(p) < 0) THEN (* 'THIS' < 'p' *)
  736. ***** ^ not supported yet
  737. ***** ^ not supported yet
  738. ***** ^ not supported yet
  739. 341 _Delete(p^.Left,h);
  740. ***** ^ not supported yet
  741. ***** ^ not supported yet
  742. ***** ^ not supported yet
  743. ***** ^ not supported yet
  744. 342 IF h THEN
  745. 343 r_Balance(p,h);
  746. ***** ^ not supported yet
  747. ***** ^ not supported yet
  748. ***** ^ not supported yet
  749. 344 END;
  750. 345 ELSIF (x.Compare(p) > 0) THEN (* 'THIS' > 'p' *)
  751. ***** ^ not supported yet
  752. ***** ^ not supported yet
  753. ***** ^ not supported yet
  754. 346 _Delete(p^.Right,h);
  755. ***** ^ not supported yet
  756. ***** ^ not supported yet
  757. ***** ^ not supported yet
  758. ***** ^ not supported yet
  759. 347 IF h THEN
  760. 348 l_Balance(p,h);
  761. ***** ^ not supported yet
  762. ***** ^ not supported yet
  763. ***** ^ not supported yet
  764. 349 END;
  765. 350 ELSE (* Found it! *)
  766. 351 q := p;
  767. ***** ^ not supported yet
  768. ***** ^ not supported yet
  769. 352 IF (q^.Right = NIL) THEN
  770. ***** ^ not supported yet
  771. ***** ^ not supported yet
  772. 353 p := q^.Left;
  773. ***** ^ not supported yet
  774. ***** ^ not supported yet
  775. ***** ^ not supported yet
  776. 354 h := TRUE;
  777. 355 ELSIF (q^.Left = NIL) THEN
  778. ***** ^ not supported yet
  779. ***** ^ not supported yet
  780. 356 p := q^.Right;
  781. ***** ^ not supported yet
  782. ***** ^ not supported yet
  783. ***** ^ not supported yet
  784. 357 h := TRUE;
  785. 358 ELSE
  786. 359 DeleteLeaf(q^.Left,h);
  787. ***** ^ not supported yet
  788. ***** ^ not supported yet
  789. ***** ^ not supported yet
  790. ***** ^ not supported yet
  791. 360 IF h THEN
  792. 361 r_Balance(p,h);
  793. ***** ^ not supported yet
  794. ***** ^ not supported yet
  795. ***** ^ not supported yet
  796. 362 END;
  797. 363 END;
  798. 364 DISPOSE(q);
  799. ***** ^ undeclared identifier
  800. ***** ^ not supported yet
  801. 365 END;
  802. 366 END _Delete;
  803. ***** ^ not supported yet
  804. 367
  805. 368 VAR
  806. 369 h : BOOLEAN;
  807. 370
  808. 371 BEGIN
  809. 372 IF (Root = NIL) THEN
  810. ***** ^ undeclared identifier
  811. 373 RETURN;
  812. 374 END;
  813. 375 IF (Root # NIL) AND (ADR(x.Compare) # ADR(Root^.Compare)) THEN
  814. ***** ^ undeclared identifier
  815. ***** ^ undeclared identifier
  816. ***** ^ not supported yet
  817. ***** ^ not supported yet
  818. ***** ^ undeclared identifier
  819. ***** ^ undeclared identifier
  820. ***** ^ not supported yet
  821. 376 (* 'x' is not the same type as tree members *)
  822. 377 Lib.FatalError('object not compatible with table');
  823. ***** ^ not supported yet
  824. ***** ^ not supported yet
  825. ***** ^ not supported yet
  826. 378 END;
  827. 379 _Delete(Root,h);
  828. ***** ^ not supported yet
  829. ***** ^ undeclared identifier
  830. ***** ^ not supported yet
  831. 380 END Delete;
  832. ***** ^ not supported yet
  833. 381
  834. 382 PROCEDURE Apply( p : Action );
  835. ***** ^ undeclared identifier
  836. 383 (* Apply a procedure to all table elements in order *)
  837. 384
  838. 385 PROCEDURE ApplyToElement( s : ElementPtr );
  839. ***** ^ undeclared identifier
  840. 386 (* Apply 'p' to left sub-tree of s, then s, then the
  841. 387 right sub-tree of s.
  842. 388 *)
  843. 389 BEGIN
  844. 390 IF (s = NIL) THEN
  845. ***** ^ not supported yet
  846. 391 RETURN;
  847. 392 ELSE
  848. 393 ApplyToElement(s^.Left);
  849. ***** ^ not supported yet
  850. ***** ^ not supported yet
  851. ***** ^ not supported yet
  852. 394 p(s);
  853. ***** ^ not supported yet
  854. ***** ^ not supported yet
  855. 395 ApplyToElement(s^.Right);
  856. ***** ^ not supported yet
  857. ***** ^ not supported yet
  858. ***** ^ not supported yet
  859. 396 END;
  860. 397 END ApplyToElement;
  861. ***** ^ not supported yet
  862. 398
  863. 399 BEGIN
  864. 400 ApplyToElement(Root);
  865. ***** ^ not supported yet
  866. ***** ^ undeclared identifier
  867. 401 END Apply;
  868. ***** ^ not supported yet
  869. 402
  870. 403 PROCEDURE Init;
  871. 404 (* Initialise a tree *)
  872. 405 BEGIN
  873. 406 Root := NIL;
  874. ***** ^ undeclared identifier
  875. 407 END Init;
  876. ***** ^ not supported yet
  877. 408
  878. 409
  879. 410 PROCEDURE Eq( t2 : TABLE ) : INTEGER;
  880. ***** ^ undeclared identifier
  881. 411 (* Compare 'THIS' to 't2'. Return values:
  882. 412
  883. 413 <0 'THIS' is less than 't2'
  884. 414 0 'THIS' is equal to 't2'
  885. 415 >0 'THIS' is greater than 't2'
  886. 416
  887. 417 The trees are searched from the bottom up (i.e. in
  888. 418 order) and the elements compared. The procedure
  889. 419 returns immediately a difference is detected or
  890. 420 when both trees are exhausted (and, therefore, they
  891. 421 must be equal). This process is implemented iteratively
  892. 422 rather than recursively.
  893. 423 *)
  894. 424
  895. 425 VAR
  896. 426 S1,
  897. 427 S2 : ARRAY [1..32] OF ElementPtr;
  898. ***** ^ not supported yet
  899. ***** ^ undeclared identifier
  900. 428 r1,
  901. 429 r2 : ElementPtr;
  902. ***** ^ undeclared identifier
  903. 430 sp1,
  904. 431 sp2 : CARDINAL;
  905. 432 res : INTEGER;
  906. 433
  907. 434 BEGIN
  908. 435 r1 := Root;
  909. ***** ^ not supported yet
  910. ***** ^ undeclared identifier
  911. 436 r2 := t2.Root;
  912. ***** ^ not supported yet
  913. ***** ^ not supported yet
  914. ***** ^ not supported yet
  915. 437 IF (r1 # NIL) AND (r1 # r2) AND (ADR(r1^.Compare) # ADR(r2^.Compare)) THEN
  916. ***** ^ not supported yet
  917. ***** ^ not supported yet
  918. ***** ^ not supported yet
  919. ***** ^ undeclared identifier
  920. ***** ^ not supported yet
  921. ***** ^ not supported yet
  922. ***** ^ undeclared identifier
  923. ***** ^ not supported yet
  924. ***** ^ not supported yet
  925. 438 (* Both trees must contain the same sort of element *)
  926. 439 Lib.FatalError(' not compareable ');
  927. ***** ^ not supported yet
  928. ***** ^ not supported yet
  929. ***** ^ not supported yet
  930. 440 END;
  931. 441 sp1 := 0;
  932. 442 sp2 := 0;
  933. 443 LOOP
  934. 444 WHILE (r1 # NIL) DO (* Build left edge array for 'THIS' *)
  935. ***** ^ not supported yet
  936. 445 INC(sp1);
  937. ***** ^ undeclared identifier
  938. ***** ^ not supported yet
  939. 446 S1[sp1] := r1;
  940. ***** ^ not supported yet
  941. ***** ^ not supported yet
  942. ***** ^ not supported yet
  943. 447 r1 := r1^.Left;
  944. ***** ^ not supported yet
  945. ***** ^ not supported yet
  946. ***** ^ not supported yet
  947. 448 END;
  948. 449 WHILE (r2 # NIL) DO (* Build left edge array for 't2' *)
  949. ***** ^ not supported yet
  950. 450 INC(sp2);
  951. ***** ^ undeclared identifier
  952. ***** ^ not supported yet
  953. 451 S2[sp2] := r2;
  954. ***** ^ not supported yet
  955. ***** ^ not supported yet
  956. ***** ^ not supported yet
  957. 452 r2 := r2^.Left;
  958. ***** ^ not supported yet
  959. ***** ^ not supported yet
  960. ***** ^ not supported yet
  961. 453 END;
  962. 454 IF (sp1 = 0) THEN (* No left sub-tree for 'THIS' *)
  963. 455 IF (sp2 = 0) THEN (* No left sub-tree for 't2' *)
  964. 456 RETURN 0; (* Implies they are equal *)
  965. 457 ELSE
  966. 458 RETURN -1; (* 'THIS' < 't2' *)
  967. 459 END;
  968. 460 ELSIF (sp2 = 0) THEN (* No left sub-tree for 't2' *)
  969. 461 RETURN 1; (* 'THIS' > 't2' *)
  970. 462 ELSE
  971. 463 r1 := S1[sp1];
  972. ***** ^ not supported yet
  973. ***** ^ not supported yet
  974. ***** ^ not supported yet
  975. 464 DEC(sp1);
  976. ***** ^ undeclared identifier
  977. ***** ^ not supported yet
  978. 465 r2 := S2[sp2];
  979. ***** ^ not supported yet
  980. ***** ^ not supported yet
  981. ***** ^ not supported yet
  982. 466 DEC(sp2);
  983. ***** ^ undeclared identifier
  984. ***** ^ not supported yet
  985. 467 END;
  986. 468 res := r1^.Compare(r2); (* Compare extreme left of both *)
  987. ***** ^ not supported yet
  988. ***** ^ not supported yet
  989. ***** ^ not supported yet
  990. 469 IF (res # 0) THEN (* These are different! *)
  991. 470 RETURN res; (* Return how they are different *)
  992. 471 END;
  993. 472 r1 := r1^.Right;
  994. ***** ^ not supported yet
  995. ***** ^ not supported yet
  996. ***** ^ not supported yet
  997. 473 r2 := r2^.Right;
  998. ***** ^ not supported yet
  999. ***** ^ not supported yet
  1000. ***** ^ not supported yet
  1001. 474 END (* LOOP *);
  1002. 475 END Eq;
  1003. ***** ^ not supported yet
  1004. 476
  1005. 477 PROCEDURE SubSet( t2 : TABLE ) : BOOLEAN;
  1006. ***** ^ undeclared identifier
  1007. 478 (* Are the elements of 'THIS' table a sub set of the elements
  1008. 479 of the table 't2'?
  1009. 480 The procedure scans scans the trees in order looking for
  1010. 481 an initial point of equality. Then 'THIS' is compared to
  1011. 482 this sub-tree of 't2' until either an element greater than
  1012. 483 the current 'THIS' element is found, or 'THIS' is exhuasted.
  1013. 484 The process is implemented iteratively rather than
  1014. 485 recursively.
  1015. 486 *)
  1016. 487 VAR
  1017. 488 S1,
  1018. 489 S2 : ARRAY [1..32] OF ElementPtr;
  1019. ***** ^ not supported yet
  1020. ***** ^ undeclared identifier
  1021. 490 r1,
  1022. 491 r2,
  1023. 492 cr : ElementPtr;
  1024. ***** ^ undeclared identifier
  1025. 493 sp1,
  1026. 494 sp2 : CARDINAL;
  1027. 495 res : INTEGER;
  1028. 496 BEGIN
  1029. 497 IF (Root # NIL) AND (t2.Root # Root) AND (ADR(Root^.Compare) # ADR(t2.Root^.Compare)) THEN
  1030. ***** ^ undeclared identifier
  1031. ***** ^ not supported yet
  1032. ***** ^ not supported yet
  1033. ***** ^ undeclared identifier
  1034. ***** ^ undeclared identifier
  1035. ***** ^ undeclared identifier
  1036. ***** ^ not supported yet
  1037. ***** ^ undeclared identifier
  1038. ***** ^ not supported yet
  1039. ***** ^ not supported yet
  1040. ***** ^ not supported yet
  1041. 498 (* Both trees must contain the same type of element *)
  1042. 499 Lib.FatalError('different types');
  1043. ***** ^ not supported yet
  1044. ***** ^ not supported yet
  1045. ***** ^ not supported yet
  1046. 500 END;
  1047. 501 r1 := Root;
  1048. ***** ^ not supported yet
  1049. ***** ^ undeclared identifier
  1050. 502 r2 := t2.Root;
  1051. ***** ^ not supported yet
  1052. ***** ^ not supported yet
  1053. ***** ^ not supported yet
  1054. 503 sp1 := 0;
  1055. 504 sp2 := 0;
  1056. 505 LOOP
  1057. 506 WHILE (r1 # NIL) DO
  1058. ***** ^ not supported yet
  1059. 507 INC(sp1);
  1060. ***** ^ undeclared identifier
  1061. ***** ^ not supported yet
  1062. 508 S1[sp1] := r1;
  1063. ***** ^ not supported yet
  1064. ***** ^ not supported yet
  1065. ***** ^ not supported yet
  1066. 509 r1 := r1^.Left;
  1067. ***** ^ not supported yet
  1068. ***** ^ not supported yet
  1069. ***** ^ not supported yet
  1070. 510 END;
  1071. 511 IF (sp1 = 0) THEN (* End of 'THIS' => is a sub-tree *)
  1072. 512 RETURN TRUE;
  1073. 513 END;
  1074. 514 r1 := S1[sp1];
  1075. ***** ^ not supported yet
  1076. ***** ^ not supported yet
  1077. ***** ^ not supported yet
  1078. 515 DEC(sp1);
  1079. ***** ^ undeclared identifier
  1080. ***** ^ not supported yet
  1081. 516 cr := r1;
  1082. ***** ^ not supported yet
  1083. ***** ^ not supported yet
  1084. 517 r1 := r1^.Right;
  1085. ***** ^ not supported yet
  1086. ***** ^ not supported yet
  1087. ***** ^ not supported yet
  1088. 518 LOOP
  1089. 519 WHILE (r2 # NIL) DO
  1090. ***** ^ not supported yet
  1091. 520 INC(sp2);
  1092. ***** ^ undeclared identifier
  1093. ***** ^ not supported yet
  1094. 521 S2[sp2] := r2;
  1095. ***** ^ not supported yet
  1096. ***** ^ not supported yet
  1097. ***** ^ not supported yet
  1098. 522 r2 := r2^.Left;
  1099. ***** ^ not supported yet
  1100. ***** ^ not supported yet
  1101. ***** ^ not supported yet
  1102. 523 END;
  1103. 524 IF (sp2 = 0) THEN (* End of 't2' => not a sub-tree *)
  1104. 525 RETURN FALSE;
  1105. 526 ELSE
  1106. 527 r2 := S2[sp2];
  1107. ***** ^ not supported yet
  1108. ***** ^ not supported yet
  1109. ***** ^ not supported yet
  1110. 528 DEC(sp2);
  1111. ***** ^ undeclared identifier
  1112. ***** ^ not supported yet
  1113. 529 END;
  1114. 530 res := cr^.Compare(r2);
  1115. ***** ^ not supported yet
  1116. ***** ^ not supported yet
  1117. ***** ^ not supported yet
  1118. 531 r2 := r2^.Right;
  1119. ***** ^ not supported yet
  1120. ***** ^ not supported yet
  1121. ***** ^ not supported yet
  1122. 532 IF (res < 0) THEN
  1123. 533 RETURN FALSE;
  1124. 534 ELSIF (res = 0) THEN
  1125. 535 EXIT;
  1126. 536 END;
  1127. 537 END (* LOOP *);
  1128. 538 END (* LOOP *);
  1129. 539 END SubSet;
  1130. ***** ^ not supported yet
  1131. 540
  1132. 541 PROCEDURE Copy() : TABLE;
  1133. ***** ^ undeclared identifier
  1134. 542 (* Make a copy of 'THIS' *)
  1135. 543
  1136. 544 PROCEDURE _Copy( r : ElementPtr ) : ElementPtr;
  1137. ***** ^ undeclared identifier
  1138. ***** ^ undeclared identifier
  1139. 545 (* Recursively generate a copy of 'r' *)
  1140. 546 VAR
  1141. 547 x : ElementPtr;
  1142. ***** ^ undeclared identifier
  1143. 548 BEGIN
  1144. 549 IF (r # NIL) THEN
  1145. ***** ^ not supported yet
  1146. 550 ALLOCATE(x,SIZE(r^));
  1147. ***** ^ not supported yet
  1148. ***** ^ not supported yet
  1149. ***** ^ undeclared identifier
  1150. ***** ^ not supported yet
  1151. 551 Lib.Move(r,x,SIZE(r^));
  1152. ***** ^ not supported yet
  1153. ***** ^ not supported yet
  1154. ***** ^ not supported yet
  1155. ***** ^ not supported yet
  1156. ***** ^ undeclared identifier
  1157. ***** ^ not supported yet
  1158. 552 x^.Left := _Copy(r^.Left);
  1159. ***** ^ not supported yet
  1160. ***** ^ not supported yet
  1161. ***** ^ not supported yet
  1162. ***** ^ not supported yet
  1163. ***** ^ not supported yet
  1164. 553 x^.Right := _Copy(r^.Right);
  1165. ***** ^ not supported yet
  1166. ***** ^ not supported yet
  1167. ***** ^ not supported yet
  1168. ***** ^ not supported yet
  1169. ***** ^ not supported yet
  1170. 554 RETURN x;
  1171. ***** ^ not supported yet
  1172. 555 ELSE
  1173. 556 RETURN r;
  1174. ***** ^ not supported yet
  1175. 557 END;
  1176. 558 END _Copy;
  1177. ***** ^ not supported yet
  1178. 559
  1179. 560 VAR
  1180. 561 NewTree : TABLE;
  1181. ***** ^ undeclared identifier
  1182. 562 BEGIN
  1183. 563 NewTree.Root := _Copy(Root);
  1184. ***** ^ not supported yet
  1185. ***** ^ not supported yet
  1186. ***** ^ not supported yet
  1187. ***** ^ undeclared identifier
  1188. 564 RETURN NewTree;
  1189. ***** ^ not supported yet
  1190. 565 END Copy;
  1191. ***** ^ not supported yet
  1192. 566
  1193. 567 PROCEDURE Incl( t2 : TABLE);
  1194. ***** ^ undeclared identifier
  1195. 568 (* Include 't2' in 'THIS' tree *)
  1196. 569
  1197. 570 PROCEDURE _Incl( r : ElementPtr );
  1198. ***** ^ undeclared identifier
  1199. 571 (* Recursively insert 'r' into 'THIS' *)
  1200. 572 BEGIN
  1201. 573 IF (r # NIL) THEN
  1202. ***** ^ not supported yet
  1203. 574 _Incl(r^.Left);
  1204. ***** ^ not supported yet
  1205. ***** ^ not supported yet
  1206. ***** ^ not supported yet
  1207. 575 _Incl(r^.Right);
  1208. ***** ^ not supported yet
  1209. ***** ^ not supported yet
  1210. ***** ^ not supported yet
  1211. 576 Insert(r^);
  1212. ***** ^ not supported yet
  1213. ***** ^ not supported yet
  1214. 577 END;
  1215. 578 END _Incl;
  1216. ***** ^ not supported yet
  1217. 579
  1218. 580 BEGIN
  1219. 581 IF (Root # NIL) AND (t2.Root # Root) AND (ADR(Root^.Compare) # ADR(t2.Root^.Compare)) THEN
  1220. ***** ^ undeclared identifier
  1221. ***** ^ not supported yet
  1222. ***** ^ not supported yet
  1223. ***** ^ undeclared identifier
  1224. ***** ^ undeclared identifier
  1225. ***** ^ undeclared identifier
  1226. ***** ^ not supported yet
  1227. ***** ^ undeclared identifier
  1228. ***** ^ not supported yet
  1229. ***** ^ not supported yet
  1230. ***** ^ not supported yet
  1231. 582 Lib.FatalError('different types');
  1232. ***** ^ not supported yet
  1233. ***** ^ not supported yet
  1234. ***** ^ not supported yet
  1235. 583 END;
  1236. 584 _Incl(t2.Root);
  1237. ***** ^ not supported yet
  1238. ***** ^ not supported yet
  1239. ***** ^ not supported yet
  1240. 585 END Incl;
  1241. ***** ^ not supported yet
  1242. 586
  1243. 587
  1244. 588 PROCEDURE Excl( t2 : TABLE);
  1245. ***** ^ undeclared identifier
  1246. 589 (* Exclude elements of 't2' from 'THIS' *)
  1247. 590
  1248. 591 PROCEDURE _Excl( r: ElementPtr );
  1249. ***** ^ undeclared identifier
  1250. 592 (* Recursively exclude 'r' from 'THIS' *)
  1251. 593 BEGIN
  1252. 594 IF (r # NIL) THEN
  1253. ***** ^ not supported yet
  1254. 595 _Excl(r^.Left);
  1255. ***** ^ not supported yet
  1256. ***** ^ not supported yet
  1257. ***** ^ not supported yet
  1258. 596 _Excl(r^.Right);
  1259. ***** ^ not supported yet
  1260. ***** ^ not supported yet
  1261. ***** ^ not supported yet
  1262. 597 Delete(r^);
  1263. ***** ^ not supported yet
  1264. ***** ^ not supported yet
  1265. 598 END;
  1266. 599 END _Excl;
  1267. ***** ^ not supported yet
  1268. 600
  1269. 601 BEGIN
  1270. 602 IF (Root # NIL) AND (t2.Root # Root) AND (ADR(Root^.Compare) # ADR(t2.Root^.Compare)) THEN
  1271. ***** ^ undeclared identifier
  1272. ***** ^ not supported yet
  1273. ***** ^ not supported yet
  1274. ***** ^ undeclared identifier
  1275. ***** ^ undeclared identifier
  1276. ***** ^ undeclared identifier
  1277. ***** ^ not supported yet
  1278. ***** ^ undeclared identifier
  1279. ***** ^ not supported yet
  1280. ***** ^ not supported yet
  1281. ***** ^ not supported yet
  1282. 603 Lib.FatalError('different types');
  1283. ***** ^ not supported yet
  1284. ***** ^ not supported yet
  1285. ***** ^ not supported yet
  1286. 604 END;
  1287. 605 _Excl(t2.Root);
  1288. ***** ^ not supported yet
  1289. ***** ^ not supported yet
  1290. ***** ^ not supported yet
  1291. 606 END Excl;
  1292. ***** ^ not supported yet
  1293. 607
  1294. 608 PROCEDURE Empty() : BOOLEAN;
  1295. 609 (* Is 'THIS' empty? *)
  1296. 610 BEGIN
  1297. 611 RETURN (Root = NIL);
  1298. ***** ^ undeclared identifier
  1299. 612 END Empty;
  1300. ***** ^ not supported yet
  1301. 613
  1302. 614 PROCEDURE Dispose;
  1303. 615 (* Dispose of entire tree *)
  1304. 616
  1305. 617 PROCEDURE _Dispose( r : ElementPtr );
  1306. ***** ^ undeclared identifier
  1307. 618 (* Recursively dispose of each element of 'r' *)
  1308. 619 BEGIN
  1309. 620 IF (r # NIL) THEN
  1310. ***** ^ not supported yet
  1311. 621 _Dispose(r^.Left); (* Delete left sub-tree *)
  1312. ***** ^ not supported yet
  1313. ***** ^ not supported yet
  1314. ***** ^ not supported yet
  1315. 622 _Dispose(r^.Right); (* Delete right sub-tree *)
  1316. ***** ^ not supported yet
  1317. ***** ^ not supported yet
  1318. ***** ^ not supported yet
  1319. 623 DISPOSE(r);
  1320. ***** ^ undeclared identifier
  1321. ***** ^ not supported yet
  1322. 624 END;
  1323. 625 END _Dispose;
  1324. ***** ^ not supported yet
  1325. 626
  1326. 627 BEGIN
  1327. 628 _Dispose(Root);
  1328. ***** ^ not supported yet
  1329. ***** ^ undeclared identifier
  1330. 629 END Dispose;
  1331. ***** ^ not supported yet
  1332. 630
  1333. 631 BEGIN
  1334. 632
  1335. 633 END TABLE ;
  1336. ***** ^ not supported yet
  1337. 634
  1338. 635
  1339. 636 END Table.
  1340. ***** ^ not supported yet
  1341. 703 errors