HASH.LST 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. Listing:
  2. 1 IMPLEMENTATION MODULE Hash;
  3. 2 (*
  4. 3 * REPERTOIRE
  5. 4 * Release 1.6
  6. 5 * By Charles Bradford and Cole Brecheen
  7. 6 * (c) Copyright 1985-1992 PMI
  8. 7 * Green Bay, Wisconsin
  9. 8 * All rights reserved
  10. 9 * (414) 468-6040
  11. 10 *
  12. 11 * $Header: D:/logfiles/mods/hash.mov 1.5 10 Mar 1991 15:28:22 coleb $
  13. 12 *
  14. 13 *
  15. 14 * Written and contributed by Jonathan March, of San Francisco.
  16. 15 *
  17. 16 *)
  18. 17
  19. 18
  20. 19 (* This module must be compiled with all runtime arithmetic checking
  21. 20 turned off. The Compute procedure depends on an overflow. *)
  22. 21
  23. 22 (*# check(overflow => off) *)
  24. 23 (* This turns off overflow checking for the JPI compiler. *)
  25. 24
  26. 25 (*/NOCHECK:O*)
  27. 26 (* And this does it for Stony Brook. *)
  28. 27
  29. 28 IMPORT ErrorManager;
  30. 29 IMPORT LowLevel;
  31. 30 IMPORT SYSTEM;
  32. 31 IMPORT VStorage;
  33. 32
  34. 33
  35. 34 VAR
  36. 35 Initialized : BOOLEAN;
  37. 36
  38. 37 PROCEDURE Init();
  39. 38 BEGIN
  40. 39 IF Initialized THEN
  41. 40 RETURN;
  42. 41 ELSE
  43. 42 Initialized := TRUE;
  44. 43 END;
  45. 44 ErrorManager.Init();
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. 45 LowLevel.Init();
  50. ***** ^ not supported yet
  51. ***** ^ not supported yet
  52. ***** ^ not supported yet
  53. 46 VStorage.Init();
  54. ***** ^ not supported yet
  55. ***** ^ not supported yet
  56. ***** ^ not supported yet
  57. 47 END Init;
  58. ***** ^ not supported yet
  59. 48
  60. 49 CONST
  61. 50 MaxTable = 999;
  62. 51 (* Note: this is just an error-checking limit. The table is allocated *)
  63. 52 (* dynamically, so MaxTable is just an upper limit to that allocation. *)
  64. 53 (* It can be changed with no side effects if desired. *)
  65. 54
  66. 55 InitCodeValue = 25967; (* arbitrary. *)
  67. 56
  68. 57 TYPE HashTable = POINTER TO HashHeader;
  69. ***** ^ undeclared identifier
  70. 58
  71. 59 TYPE
  72. 60 NodePtr = POINTER TO Node;
  73. ***** ^ undeclared identifier
  74. 61
  75. 62 Node =
  76. 63 RECORD
  77. 64 next : NodePtr;
  78. 65 (* next node in this bin in hash table *)
  79. 66 hash2, hash3 : CARDINAL;
  80. 67 (* stored in lieu of actual key *)
  81. 68 hData : ARRAY [0..1] OF SYSTEM.BYTE;
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. 69 (* Dummy. Data is actually longer... *)
  85. 70 END; (* record *)
  86. ***** ^ not supported yet
  87. 71
  88. 72 BinHeader =
  89. 73 RECORD
  90. 74 first : NodePtr;
  91. 75 binCount : CARDINAL; (* diagnostic use only. *)
  92. 76 END; (* record *)
  93. ***** ^ not supported yet
  94. 77
  95. 78 HashArray = ARRAY [0..MaxTable-1] OF BinHeader;
  96. ***** ^ not supported yet
  97. ***** ^ not supported yet
  98. 79
  99. 80 HashHeader =
  100. 81 RECORD
  101. 82 initCode : CARDINAL; (* will be InitCodeValue if initialized. *)
  102. 83 binCount : CARDINAL; (* n of bins in hash table *)
  103. 84 tableCount : CARDINAL; (* n entries currently in table. *)
  104. 85 dataSize : CARDINAL; (* n bytes of user data per entry *)
  105. 86 nodeSize : CARDINAL; (* n bytes allocated per entry *)
  106. 87 tablePtr : POINTER TO HashArray; (* array of bin headers *)
  107. ***** ^ not supported yet
  108. 88 currentBinNum: CARDINAL; (* index of last bin accessed *)
  109. 89 currentNode : NodePtr; (* last node accessed. NIL if none. *)
  110. 90 parentNode : NodePtr; (* parent node of currentNode. NIL if top. *)
  111. 91 END; (* record *)
  112. ***** ^ not supported yet
  113. 92
  114. 93
  115. 94 PROCEDURE Define
  116. 95 ( VAR table : HashTable; (* out *)
  117. 96 numberBins : CARDINAL; (* in *)
  118. 97 dataBytes : CARDINAL (* in - bytes per data *)
  119. 98 );
  120. 99 (* Create and initialize a hash table. Number of bins would typically be
  121. 100 about the same as the number of expected entries; more for speed, less
  122. 101 for space saving. The number of bins will be increased by 1 if even.
  123. 102 Note that the size of all user data in this table will be required to
  124. 103 be "dataBytes" *)
  125. 104 VAR
  126. 105 i : CARDINAL;
  127. 106 BEGIN (* procedure HashDefine *)
  128. 107 IF (numberBins<2) OR (numberBins>MaxTable) THEN
  129. 108 ErrorManager.CallHalt(
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. 109 "Programmer error initializing hash table: bad table size.");
  133. ***** ^ not supported yet
  134. 110 END; (* if numberBins *)
  135. 111 VStorage.DosAlloc(table, SYSTEM.TSIZE(HashHeader) );
  136. ***** ^ not supported yet
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. ***** ^ not supported yet
  140. ***** ^ not supported yet
  141. ***** ^ not supported yet
  142. 112 WITH table^ DO
  143. ***** ^ not supported yet
  144. 113 binCount := CARDINAL( BITSET(numberBins) + BITSET(1)); (* force odd *)
  145. ***** ^ undeclared identifier
  146. ***** ^ undeclared identifier
  147. ***** ^ not supported yet
  148. ***** ^ undeclared identifier
  149. ***** ^ not supported yet
  150. 114 dataSize := dataBytes; (* bytes of user data per element *)
  151. ***** ^ undeclared identifier
  152. 115 nodeSize := SYSTEM.TSIZE( Node) - 2 + dataSize;
  153. ***** ^ undeclared identifier
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. ***** ^ not supported yet
  157. ***** ^ undeclared identifier
  158. 116 (* byte allocated per element. *)
  159. 117 tableCount:= 0;
  160. ***** ^ undeclared identifier
  161. 118 currentBinNum := 0;
  162. ***** ^ undeclared identifier
  163. 119 currentNode := NIL;
  164. ***** ^ undeclared identifier
  165. 120 parentNode := NIL;
  166. ***** ^ undeclared identifier
  167. 121 VStorage.DosAlloc( tablePtr, SYSTEM.TSIZE( BinHeader) * binCount );
  168. ***** ^ not supported yet
  169. ***** ^ not supported yet
  170. ***** ^ undeclared identifier
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. ***** ^ undeclared identifier
  175. 122 FOR i := 0 TO binCount-1 DO
  176. ***** ^ undeclared identifier
  177. ***** ^ FOR needs integer variable and bounds
  178. 123 WITH tablePtr^[i] DO
  179. ***** ^ undeclared identifier
  180. ***** ^ not supported yet
  181. 124 first := NIL;
  182. ***** ^ undeclared identifier
  183. 125 binCount := 0;
  184. ***** ^ undeclared identifier
  185. 126 END; (* with tablePtr *)
  186. ***** ^ not supported yet
  187. 127 END; (* for i *)
  188. 128 initCode := InitCodeValue;
  189. ***** ^ undeclared identifier
  190. 129 END; (* with table *)
  191. ***** ^ not supported yet
  192. 130 END Define; (* procedure *)
  193. ***** ^ not supported yet
  194. 131
  195. 132
  196. 133 PROCEDURE Dispose( VAR table : HashTable); (* out *)
  197. 134 (* releases all memory associated with the table. Table becomes NIL. *)
  198. 135 (* Does nothing if table was not initialized. *)
  199. 136 VAR
  200. 137 pNode, qNode : NodePtr;
  201. ***** ^ not supported yet
  202. 138 count, iNode : CARDINAL;
  203. 139 BEGIN (* procedure HashDispose *)
  204. 140 count := 0;
  205. 141 IF table # NIL THEN
  206. ***** ^ not supported yet
  207. 142 WITH table^ DO
  208. ***** ^ not supported yet
  209. 143 IF initCode = InitCodeValue THEN
  210. ***** ^ undeclared identifier
  211. 144 FOR iNode := 0 TO binCount-1 DO
  212. ***** ^ undeclared identifier
  213. ***** ^ FOR needs integer variable and bounds
  214. 145 WITH tablePtr^[iNode] DO
  215. ***** ^ undeclared identifier
  216. ***** ^ not supported yet
  217. 146 pNode := first;
  218. ***** ^ not supported yet
  219. ***** ^ undeclared identifier
  220. 147 WHILE pNode # NIL DO
  221. ***** ^ not supported yet
  222. 148 INC( count);
  223. ***** ^ undeclared identifier
  224. ***** ^ not supported yet
  225. 149 qNode := pNode^.next;
  226. ***** ^ not supported yet
  227. ***** ^ not supported yet
  228. ***** ^ not supported yet
  229. 150 VStorage.DosDealloc( pNode, nodeSize);
  230. ***** ^ not supported yet
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. ***** ^ undeclared identifier
  234. 151 pNode := qNode;
  235. ***** ^ not supported yet
  236. ***** ^ not supported yet
  237. 152 END; (* while pNode *)
  238. 153 END; (* with tablePtr *)
  239. ***** ^ not supported yet
  240. 154 END; (* for iNode *)
  241. 155 VStorage.DosDealloc( tablePtr, SYSTEM.TSIZE( BinHeader)* binCount);
  242. ***** ^ not supported yet
  243. ***** ^ not supported yet
  244. ***** ^ undeclared identifier
  245. ***** ^ not supported yet
  246. ***** ^ not supported yet
  247. ***** ^ not supported yet
  248. ***** ^ undeclared identifier
  249. 156 IF count # tableCount THEN
  250. ***** ^ undeclared identifier
  251. ***** ^ undeclared identifier
  252. 157 ErrorManager.CallHalt( "Hash table memory corruption detected.");
  253. ***** ^ not supported yet
  254. ***** ^ not supported yet
  255. ***** ^ not supported yet
  256. 158 END; (* if count *)
  257. 159 END; (* if initCode *)
  258. 160 initCode := 0; (* in case memory location is re-used. *)
  259. ***** ^ undeclared identifier
  260. 161 END; (* with table *)
  261. ***** ^ not supported yet
  262. 162 VStorage.DosDealloc( table, SYSTEM.TSIZE(HashHeader) );
  263. ***** ^ not supported yet
  264. ***** ^ not supported yet
  265. ***** ^ undeclared identifier
  266. ***** ^ not supported yet
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. 163 END; (* if table *)
  270. 164 END Dispose; (* procedure *)
  271. ***** ^ not supported yet
  272. 165
  273. 166
  274. 167 PROCEDURE InitCheck(table : HashTable);
  275. 168 (* Internal only *)
  276. 169 BEGIN (* procedure InitCheck *)
  277. 170 IF (table = NIL) OR (table^.initCode # InitCodeValue) THEN
  278. ***** ^ not supported yet
  279. ***** ^ not supported yet
  280. ***** ^ not supported yet
  281. 171 ErrorManager.CallHalt( "Programmer error: uninitialized hash table.");
  282. ***** ^ not supported yet
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. 172 END; (* if table *)
  286. 173 END InitCheck; (* procedure *)
  287. ***** ^ not supported yet
  288. 174
  289. 175 (* ALL THE FOLLOWING PROCEDURES WILL HALT THE PROGRAM IF CALLED WITH AN *)
  290. 176 (* UNINITIALIZED TABLE. Initialization is the programmer's responsibility. *)
  291. 177
  292. 178
  293. 179 (*$O-*)
  294. 180 PROCEDURE Compute( key : ARRAY OF SYSTEM.BYTE;
  295. ***** ^ not supported yet
  296. 181 VAR hash1, hash2, hash3 : CARDINAL);
  297. 182 (* return 3 independent hashed values of the key. *)
  298. 183 VAR
  299. 184 i, j, in1, in2 : CARDINAL;
  300. 185 temp1, temp2, temp3 : CARDINAL;
  301. 186 BEGIN (* procedure Compute *)
  302. 187 (*$R-*)(*$T-*)
  303. 188 temp1 := 5555H;
  304. 189 temp2 := 9753H;
  305. 190 temp3 := 0E069H;
  306. 191 j := HIGH(key);
  307. ***** ^ undeclared identifier
  308. ***** ^ not supported yet
  309. 192 FOR i := 0 TO HIGH(key) DO
  310. ***** ^ undeclared identifier
  311. ***** ^ not supported yet
  312. 193 (* Each byte of the key is used twice, symmetrically at opposite ends *)
  313. 194 (* of the hashing. Thus, for example, keys differing only in the last *)
  314. 195 (* byte will end up hashed completely differently. *)
  315. 196 in1 := ORD(key[i]);
  316. ***** ^ undeclared identifier
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. 197 in2 := ORD(key[j]);
  320. ***** ^ undeclared identifier
  321. ***** ^ not supported yet
  322. ***** ^ not supported yet
  323. 198 DEC(j);
  324. ***** ^ undeclared identifier
  325. ***** ^ not supported yet
  326. 199 temp1:= CARDINAL( BITSET(temp1*2) / BITSET(in1*8) / BITSET(temp2) ) +
  327. ***** ^ undeclared identifier
  328. ***** ^ not supported yet
  329. ***** ^ undeclared identifier
  330. ***** ^ not supported yet
  331. ***** ^ undeclared identifier
  332. ***** ^ not supported yet
  333. 200 temp3 DIV 128 - in2*128;
  334. 201 temp2:= CARDINAL( BITSET(temp2*4) / BITSET(in1*512 + in2) ) -
  335. ***** ^ undeclared identifier
  336. ***** ^ not supported yet
  337. ***** ^ undeclared identifier
  338. ***** ^ not supported yet
  339. 202 temp1 DIV 64 + temp3;
  340. 203 temp3:= CARDINAL( BITSET(temp3 DIV 4 - in1) / BITSET(in2*256) ) +
  341. ***** ^ undeclared identifier
  342. ***** ^ not supported yet
  343. ***** ^ undeclared identifier
  344. ***** ^ not supported yet
  345. 204 temp2 * 64 + temp1;
  346. 205 END; (* for i *)
  347. 206 hash1 := temp1;
  348. 207 hash2 := temp2;
  349. 208 hash3 := temp3;
  350. 209 (*$R=*)(*$T=*)
  351. 210 END Compute; (* procedure *)
  352. ***** ^ not supported yet
  353. 211
  354. 212
  355. 213 PROCEDURE KeyFind
  356. 214 ( table : HashTable; (* in *)
  357. 215 key : ARRAY OF SYSTEM.BYTE (* in - key to look for *)
  358. ***** ^ not supported yet
  359. 216 ) : BOOLEAN; (* out - key found? *)
  360. 217 (* See if an entry with this key already exists in this hash table. *)
  361. 218 VAR
  362. 219 h1, h2, h3 : CARDINAL;
  363. 220 BEGIN (* procedure KeyFind *)
  364. 221 InitCheck(table);
  365. ***** ^ not supported yet
  366. ***** ^ not supported yet
  367. 222 WITH table^ DO
  368. ***** ^ not supported yet
  369. 223 Compute( key, h1, h2, h3);
  370. ***** ^ not supported yet
  371. ***** ^ not supported yet
  372. ***** ^ not supported yet
  373. 224 currentBinNum := h1 MOD binCount;
  374. ***** ^ undeclared identifier
  375. ***** ^ undeclared identifier
  376. 225 currentNode := tablePtr^[currentBinNum].first;
  377. ***** ^ undeclared identifier
  378. ***** ^ undeclared identifier
  379. ***** ^ undeclared identifier
  380. ***** ^ not supported yet
  381. 226 parentNode := NIL;
  382. ***** ^ undeclared identifier
  383. 227 WHILE currentNode # NIL DO
  384. ***** ^ undeclared identifier
  385. 228 WITH currentNode^ DO
  386. ***** ^ undeclared identifier
  387. 229 IF (h2=hash2) AND (h3=hash3) THEN
  388. ***** ^ undeclared identifier
  389. ***** ^ undeclared identifier
  390. 230 RETURN TRUE;
  391. 231 END; (* if h2 *)
  392. 232 END; (* with currentNode *)
  393. ***** ^ not supported yet
  394. 233 (* no match yet, try the next node in linked list, if any: *)
  395. 234 parentNode := currentNode;
  396. ***** ^ undeclared identifier
  397. ***** ^ undeclared identifier
  398. 235 currentNode := currentNode^.next;
  399. ***** ^ undeclared identifier
  400. ***** ^ undeclared identifier
  401. ***** ^ not supported yet
  402. 236 END; (* while currentNode *)
  403. 237 (* no match in the list. *)
  404. 238 RETURN FALSE;
  405. 239 END; (* with table *)
  406. ***** ^ not supported yet
  407. 240 END KeyFind; (* procedure *)
  408. ***** ^ not supported yet
  409. 241
  410. 242
  411. 243 PROCEDURE Insert
  412. 244 ( table : HashTable; (* in/(out) *)
  413. 245 key : ARRAY OF SYSTEM.BYTE; (* in - must be unique *)
  414. ***** ^ not supported yet
  415. 246 data : ARRAY OF SYSTEM.BYTE (* in - always same size.*)
  416. ***** ^ not supported yet
  417. 247 );
  418. 248 (* Halts program if attempt is made to insert a duplicate key.
  419. 249 This is a partial safeguard against (extremely unlikely) false key matching.
  420. 250 First call KeyFind if you want to check for a duplicate before
  421. 251 inserting. *)
  422. 252 (* Inefficient, because computes the hash twice. ***** *)
  423. 253 VAR
  424. 254 h1 : CARDINAL;
  425. 255 nodeBytes : CARDINAL;
  426. 256 BEGIN (* procedure HashInsert *)
  427. 257 IF KeyFind( table, key) THEN
  428. ***** ^ not supported yet
  429. ***** ^ not supported yet
  430. ***** ^ not supported yet
  431. 258 ErrorManager.CallHalt(
  432. ***** ^ not supported yet
  433. ***** ^ not supported yet
  434. 259 "Programmer error or hash algorithm failure. Duplicate hash key.");
  435. ***** ^ not supported yet
  436. 260 END; (* if KeyFind *)
  437. 261 WITH table^ DO
  438. ***** ^ not supported yet
  439. 262 IF dataSize # (HIGH(data)+1) THEN
  440. ***** ^ undeclared identifier
  441. ***** ^ undeclared identifier
  442. ***** ^ not supported yet
  443. 263 ErrorManager.CallHalt(
  444. ***** ^ not supported yet
  445. ***** ^ not supported yet
  446. 264 "Programmer error calling HashInsert: wrong data size.");
  447. ***** ^ not supported yet
  448. 265 END; (* if dataSize *)
  449. 266 parentNode := NIL;
  450. ***** ^ undeclared identifier
  451. 267 (* allocate amount actually needed for node. *)
  452. 268 VStorage.DosAlloc( currentNode, nodeSize);
  453. ***** ^ not supported yet
  454. ***** ^ not supported yet
  455. ***** ^ undeclared identifier
  456. ***** ^ undeclared identifier
  457. 269 WITH currentNode^ DO
  458. ***** ^ undeclared identifier
  459. 270 LowLevel.Move( SYSTEM.ADR(data), SYSTEM.ADR(hData), dataSize);
  460. ***** ^ not supported yet
  461. ***** ^ not supported yet
  462. ***** ^ not supported yet
  463. ***** ^ not supported yet
  464. ***** ^ not supported yet
  465. ***** ^ not supported yet
  466. ***** ^ not supported yet
  467. ***** ^ undeclared identifier
  468. ***** ^ undeclared identifier
  469. 271 Compute( key, h1, hash2, hash3);
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. ***** ^ undeclared identifier
  473. ***** ^ undeclared identifier
  474. 272 END; (* with currentNode *)
  475. ***** ^ not supported yet
  476. 273 currentBinNum := h1 MOD binCount; (* redundant, because of KeyFind. *)
  477. ***** ^ undeclared identifier
  478. ***** ^ undeclared identifier
  479. ***** ^ undeclared identifier
  480. 274 WITH tablePtr^[currentBinNum] DO
  481. ***** ^ undeclared identifier
  482. ***** ^ undeclared identifier
  483. 275 currentNode^.next := first;
  484. ***** ^ undeclared identifier
  485. ***** ^ not supported yet
  486. ***** ^ undeclared identifier
  487. 276 first := currentNode;
  488. ***** ^ undeclared identifier
  489. ***** ^ undeclared identifier
  490. 277 INC(binCount);
  491. ***** ^ undeclared identifier
  492. ***** ^ undeclared identifier
  493. 278 END; (* with tablePtr *)
  494. ***** ^ not supported yet
  495. 279 INC( tableCount);
  496. ***** ^ undeclared identifier
  497. ***** ^ undeclared identifier
  498. 280 END; (* with table *)
  499. ***** ^ not supported yet
  500. 281 END Insert; (* procedure *)
  501. ***** ^ not supported yet
  502. 282
  503. 283
  504. 284 PROCEDURE Delete( table : HashTable);
  505. 285 (* Deletes hash table entry associated with the last Insert or KeyFind. *)
  506. 286 (* Has no effect if that element was never found or was already deleted. *)
  507. 287 VAR
  508. 288 nextNode : NodePtr;
  509. ***** ^ not supported yet
  510. 289 BEGIN (* procedure HashDelete *)
  511. 290 InitCheck(table);
  512. ***** ^ not supported yet
  513. ***** ^ not supported yet
  514. 291 WITH table^ DO
  515. ***** ^ not supported yet
  516. 292 IF currentNode # NIL THEN
  517. ***** ^ undeclared identifier
  518. 293 DEC( tableCount);
  519. ***** ^ undeclared identifier
  520. ***** ^ undeclared identifier
  521. 294 nextNode := currentNode^.next;
  522. ***** ^ not supported yet
  523. ***** ^ undeclared identifier
  524. ***** ^ not supported yet
  525. 295 VStorage.DosDealloc( currentNode, nodeSize);
  526. ***** ^ not supported yet
  527. ***** ^ not supported yet
  528. ***** ^ undeclared identifier
  529. ***** ^ undeclared identifier
  530. 296 WITH tablePtr^[ currentBinNum] DO
  531. ***** ^ undeclared identifier
  532. ***** ^ undeclared identifier
  533. 297 DEC( binCount);
  534. ***** ^ undeclared identifier
  535. ***** ^ undeclared identifier
  536. 298 IF parentNode = NIL THEN
  537. ***** ^ undeclared identifier
  538. 299 first := nextNode;
  539. ***** ^ undeclared identifier
  540. ***** ^ not supported yet
  541. 300 ELSE
  542. 301 parentNode^.next := nextNode;
  543. ***** ^ undeclared identifier
  544. ***** ^ not supported yet
  545. ***** ^ not supported yet
  546. 302 END; (* if parentNode *)
  547. 303 END; (* with tablePtr *)
  548. ***** ^ not supported yet
  549. 304 END; (* if currentNode *)
  550. 305 END; (* with table *)
  551. ***** ^ not supported yet
  552. 306 END Delete; (* procedure *)
  553. ***** ^ not supported yet
  554. 307
  555. 308
  556. 309 PROCEDURE MoveData( table : HashTable;
  557. 310 pIn, pOut : SYSTEM.ADDRESS;
  558. ***** ^ not supported yet
  559. 311 dataHigh : CARDINAL);
  560. 312 (* used in HashGetData and HashChangeData. *)
  561. 313 BEGIN (* procedure DataCheck *)
  562. 314 WITH table^ DO
  563. ***** ^ not supported yet
  564. 315 IF (currentNode = NIL) OR (dataSize # dataHigh+1) THEN
  565. ***** ^ undeclared identifier
  566. ***** ^ undeclared identifier
  567. 316 ErrorManager.CallHalt(
  568. ***** ^ not supported yet
  569. ***** ^ not supported yet
  570. 317 "Programmer error. Attempt to access hash element.");
  571. ***** ^ not supported yet
  572. 318 END; (* if currentNode *)
  573. 319 LowLevel.Move( pIn, pOut, dataSize);
  574. ***** ^ not supported yet
  575. ***** ^ not supported yet
  576. ***** ^ not supported yet
  577. ***** ^ not supported yet
  578. ***** ^ undeclared identifier
  579. 320 END; (* with table *)
  580. ***** ^ not supported yet
  581. 321 END MoveData; (* procedure *)
  582. ***** ^ not supported yet
  583. 322
  584. 323
  585. 324 PROCEDURE GetData
  586. 325 ( table : HashTable; (* in *)
  587. 326 VAR data : ARRAY OF SYSTEM.BYTE (* out - size must match. *)
  588. ***** ^ not supported yet
  589. 327 );
  590. 328 (* Gets the data associated with the last Insert or KeyFind. *)
  591. 329 (* Fails if no such element or size does not match. *)
  592. 330 BEGIN (* procedure HashGetData *)
  593. 331 InitCheck( table);
  594. ***** ^ not supported yet
  595. ***** ^ not supported yet
  596. 332 MoveData(table, SYSTEM.ADR(table^.currentNode^.hData),
  597. ***** ^ not supported yet
  598. ***** ^ not supported yet
  599. ***** ^ not supported yet
  600. ***** ^ not supported yet
  601. ***** ^ not supported yet
  602. ***** ^ not supported yet
  603. ***** ^ not supported yet
  604. 333 SYSTEM.ADR(data), HIGH(data) );
  605. ***** ^ not supported yet
  606. ***** ^ not supported yet
  607. ***** ^ not supported yet
  608. ***** ^ undeclared identifier
  609. ***** ^ not supported yet
  610. 334 END GetData; (* procedure *)
  611. ***** ^ not supported yet
  612. 335
  613. 336
  614. 337 PROCEDURE ChangeData
  615. 338 ( table : HashTable; (* in *)
  616. 339 data : ARRAY OF SYSTEM.BYTE (* in - size must match. *)
  617. ***** ^ not supported yet
  618. 340 );
  619. 341 (* Changes the data associated with the last Insert or KeyFind. *)
  620. 342 (* Fails if no such element or size does not match. *)
  621. 343 BEGIN (* procedure HashChangeData *)
  622. 344 InitCheck( table);
  623. ***** ^ not supported yet
  624. ***** ^ not supported yet
  625. 345 MoveData(table, SYSTEM.ADR(data),
  626. ***** ^ not supported yet
  627. ***** ^ not supported yet
  628. ***** ^ not supported yet
  629. ***** ^ not supported yet
  630. ***** ^ not supported yet
  631. 346 SYSTEM.ADR(table^.currentNode^.hData), HIGH(data) );
  632. ***** ^ not supported yet
  633. ***** ^ not supported yet
  634. ***** ^ not supported yet
  635. ***** ^ not supported yet
  636. ***** ^ not supported yet
  637. ***** ^ undeclared identifier
  638. ***** ^ not supported yet
  639. 347 END ChangeData; (* procedure *)
  640. ***** ^ not supported yet
  641. 348
  642. 349 PROCEDURE Size( table : HashTable) : CARDINAL;
  643. 350 (* returns the number of data entries in the hash table. *)
  644. 351 BEGIN (* procedure HashSize *)
  645. 352 IF (table=NIL) OR (table^.initCode # InitCodeValue) THEN
  646. ***** ^ not supported yet
  647. ***** ^ not supported yet
  648. ***** ^ not supported yet
  649. 353 RETURN 0;
  650. 354 END; (* if table *)
  651. 355 RETURN table^.tableCount;
  652. ***** ^ not supported yet
  653. ***** ^ not supported yet
  654. 356 END Size; (* procedure *)
  655. ***** ^ not supported yet
  656. 357
  657. 358 BEGIN
  658. 359 Initialized := FALSE;
  659. 360 Init();
  660. ***** ^ not supported yet
  661. ***** ^ not supported yet
  662. 361 END Hash. (* implementation module *)
  663. ***** ^ not supported yet
  664. 301 errors