cclasses.pas 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl and Peter Vreman
  4. This module provides some basic classes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit cclasses;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. cutils,cstreams;
  23. {$ifdef OLD}
  24. type
  25. pmemdebug = ^tmemdebug;
  26. tmemdebug = object
  27. constructor init(const s:string);
  28. destructor done;
  29. procedure show;
  30. private
  31. startmem : integer;
  32. infostr : string[40];
  33. end;
  34. {$endif OLD}
  35. {********************************************
  36. TLinkedList
  37. ********************************************}
  38. type
  39. TLinkedListItem = class
  40. public
  41. Previous,
  42. Next : TLinkedListItem;
  43. Constructor Create;
  44. Destructor Destroy;override;
  45. Function GetCopy:TLinkedListItem;virtual;
  46. end;
  47. TLinkedListItemClass = class of TLinkedListItem;
  48. TLinkedList = class
  49. private
  50. FCount : integer;
  51. FFirst,
  52. FLast : TLinkedListItem;
  53. public
  54. constructor Create;
  55. destructor Destroy;override;
  56. { true when the List is empty }
  57. function Empty:boolean;
  58. { deletes all Items }
  59. procedure Clear;
  60. { inserts an Item }
  61. procedure Insert(Item:TLinkedListItem);
  62. { concats an Item }
  63. procedure Concat(Item:TLinkedListItem);
  64. { deletes an Item }
  65. procedure Remove(Item:TLinkedListItem);
  66. { Gets First Item }
  67. function GetFirst:TLinkedListItem;
  68. { Gets last Item }
  69. function GetLast:TLinkedListItem;
  70. { inserts another List at the begin and make this List empty }
  71. procedure insertList(p : TLinkedList);
  72. { concats another List at the end and make this List empty }
  73. procedure concatList(p : TLinkedList);
  74. { concats another List at the end and makes a copy }
  75. procedure insertListcopy(p : TLinkedList);
  76. { concats another List at the end and makes a copy }
  77. procedure concatListcopy(p : TLinkedList);
  78. property First:TLinkedListItem read FFirst;
  79. property Last:TLinkedListItem read FLast;
  80. property Count:Integer read FCount;
  81. end;
  82. {********************************************
  83. TStringList
  84. ********************************************}
  85. { string containerItem }
  86. TStringListItem = class(TLinkedListItem)
  87. FPStr : PString;
  88. public
  89. constructor Create(const s:string);
  90. destructor Destroy;override;
  91. function GetCopy:TLinkedListItem;override;
  92. function Str:string;
  93. end;
  94. { string container }
  95. TStringList = class(TLinkedList)
  96. private
  97. FDoubles : boolean; { if this is set to true, doubles are allowed }
  98. public
  99. constructor Create;
  100. constructor Create_No_Double;
  101. { inserts an Item }
  102. procedure Insert(const s:string);
  103. { concats an Item }
  104. procedure Concat(const s:string);
  105. { deletes an Item }
  106. procedure Remove(const s:string);
  107. { Gets First Item }
  108. function GetFirst:string;
  109. { Gets last Item }
  110. function GetLast:string;
  111. { true if string is in the container }
  112. function Find(const s:string):TStringListItem;
  113. { inserts an object }
  114. procedure InsertItem(item:TStringListItem);
  115. { concats an object }
  116. procedure ConcatItem(item:TStringListItem);
  117. property Doubles:boolean read FDoubles write FDoubles;
  118. end;
  119. {$ifdef OLD}
  120. {********************************************
  121. Dictionary
  122. ********************************************}
  123. const
  124. { the real size will be [-hasharray..hasharray] ! }
  125. hasharraysize = 2047;
  126. type
  127. { namedindexobect for use with dictionary and indexarray }
  128. Pnamedindexobject=^Tnamedindexobject;
  129. Tnamedindexobject=object
  130. { indexarray }
  131. indexnr : integer;
  132. indexNext : Pnamedindexobject;
  133. { dictionary }
  134. _name : Pstring;
  135. _valuename : Pstring; { uppercase name }
  136. left,right : Pnamedindexobject;
  137. speedvalue : integer;
  138. { singleList }
  139. ListNext : Pnamedindexobject;
  140. constructor init;
  141. constructor initname(const n:string);
  142. destructor done;virtual;
  143. procedure setname(const n:string);virtual;
  144. function name:string;virtual;
  145. end;
  146. Pdictionaryhasharray=^Tdictionaryhasharray;
  147. Tdictionaryhasharray=array[-hasharraysize..hasharraysize] of Pnamedindexobject;
  148. Tnamedindexcallback = procedure(p:Pnamedindexobject);
  149. Pdictionary=^Tdictionary;
  150. Tdictionary=object
  151. noclear : boolean;
  152. replace_existing : boolean;
  153. constructor init;
  154. destructor done;virtual;
  155. procedure usehash;
  156. procedure clear;
  157. function delete(const s:string):Pnamedindexobject;
  158. function empty:boolean;
  159. procedure foreach(proc2call:Tnamedindexcallback);
  160. function insert(obj:Pnamedindexobject):Pnamedindexobject;
  161. function rename(const olds,News : string):Pnamedindexobject;
  162. function search(const s:string):Pnamedindexobject;
  163. function speedsearch(const s:string;speedvalue:integer):Pnamedindexobject;
  164. private
  165. root : Pnamedindexobject;
  166. hasharray : Pdictionaryhasharray;
  167. procedure cleartree(obj:Pnamedindexobject);
  168. function insertNode(NewNode:Pnamedindexobject;var currNode:Pnamedindexobject):Pnamedindexobject;
  169. procedure inserttree(currtree,currroot:Pnamedindexobject);
  170. end;
  171. psingleList=^tsingleList;
  172. tsingleList=object
  173. First,
  174. last : Pnamedindexobject;
  175. constructor init;
  176. destructor done;
  177. procedure reset;
  178. procedure clear;
  179. procedure insert(p:Pnamedindexobject);
  180. end;
  181. tindexobjectarray=array[1..16000] of Pnamedindexobject;
  182. Pnamedindexobjectarray=^tindexobjectarray;
  183. pindexarray=^tindexarray;
  184. tindexarray=object
  185. noclear : boolean;
  186. First : Pnamedindexobject;
  187. count : integer;
  188. constructor init(Agrowsize:integer);
  189. destructor done;
  190. procedure clear;
  191. procedure foreach(proc2call : Tnamedindexcallback);
  192. procedure deleteindex(p:Pnamedindexobject);
  193. procedure delete(var p:Pnamedindexobject);
  194. procedure insert(p:Pnamedindexobject);
  195. function search(nr:integer):Pnamedindexobject;
  196. private
  197. growsize,
  198. size : integer;
  199. data : Pnamedindexobjectarray;
  200. procedure grow(gsize:integer);
  201. end;
  202. {$ifdef fixLeaksOnError}
  203. PStackItem = ^TStackItem;
  204. TStackItem = record
  205. Next: PStackItem;
  206. data: pointer;
  207. end;
  208. PStack = ^TStack;
  209. TStack = object
  210. constructor init;
  211. destructor done;
  212. procedure push(p: pointer);
  213. function pop: pointer;
  214. function top: pointer;
  215. function isEmpty: boolean;
  216. private
  217. head: PStackItem;
  218. end;
  219. {$endif fixLeaksOnError}
  220. {$endif OLD}
  221. {********************************************
  222. DynamicArray
  223. ********************************************}
  224. const
  225. dynamicblockbasesize = 12;
  226. type
  227. pdynamicblock = ^tdynamicblock;
  228. tdynamicblock = record
  229. pos,
  230. used : integer;
  231. Next : pdynamicblock;
  232. data : array[0..high(integer)-20] of byte;
  233. end;
  234. pdynamicarray = ^tdynamicarray;
  235. tdynamicarray = class
  236. private
  237. FPosn : integer;
  238. FPosnblock : pdynamicblock;
  239. FBlocksize : integer;
  240. FFirstblock,
  241. FLastblock : pdynamicblock;
  242. procedure grow;
  243. public
  244. constructor Create(Ablocksize:integer);
  245. destructor Destroy;override;
  246. function size:integer;
  247. procedure align(i:integer);
  248. procedure seek(i:integer);
  249. function read(var d;len:integer):integer;
  250. procedure write(const d;len:integer);
  251. procedure writestr(const s:string);
  252. procedure readstream(f:TCStream);
  253. procedure writestream(f:TCStream);
  254. property BlockSize : integer read FBlocksize;
  255. property FirstBlock : PDynamicBlock read FFirstBlock;
  256. end;
  257. implementation
  258. {$ifdef OLD}
  259. {*****************************************************************************
  260. Memory debug
  261. *****************************************************************************}
  262. constructor tmemdebug.init(const s:string);
  263. begin
  264. infostr:=s;
  265. {$ifdef Delphi}
  266. startmem:=0;
  267. {$else}
  268. startmem:=memavail;
  269. {$endif Delphi}
  270. end;
  271. procedure tmemdebug.show;
  272. {$ifndef Delphi}
  273. var
  274. l : integer;
  275. {$endif}
  276. begin
  277. {$ifndef Delphi}
  278. write('memory [',infostr,'] ');
  279. l:=memavail;
  280. if l>startmem then
  281. writeln(l-startmem,' released')
  282. else
  283. writeln(startmem-l,' allocated');
  284. {$endif Delphi}
  285. end;
  286. destructor tmemdebug.done;
  287. begin
  288. show;
  289. end;
  290. {*****************************************************************************
  291. Stack
  292. *****************************************************************************}
  293. {$ifdef fixLeaksOnError}
  294. constructor TStack.init;
  295. begin
  296. head := nil;
  297. end;
  298. procedure TStack.push(p: pointer);
  299. var s: PStackItem;
  300. begin
  301. New(s);
  302. s^.data := p;
  303. s^.Next := head;
  304. head := s;
  305. end;
  306. function TStack.pop: pointer;
  307. var s: PStackItem;
  308. begin
  309. pop := top;
  310. if assigned(head) then
  311. begin
  312. s := head^.Next;
  313. dispose(head);
  314. head := s;
  315. end
  316. end;
  317. function TStack.top: pointer;
  318. begin
  319. if not isEmpty then
  320. top := head^.data
  321. else top := NIL;
  322. end;
  323. function TStack.isEmpty: boolean;
  324. begin
  325. isEmpty := head = nil;
  326. end;
  327. destructor TStack.done;
  328. var temp: PStackItem;
  329. begin
  330. while head <> nil do
  331. begin
  332. temp := head^.Next;
  333. dispose(head);
  334. head := temp;
  335. end;
  336. end;
  337. {$endif fixLeaksOnError}
  338. {$endif OLD}
  339. {****************************************************************************
  340. TLinkedListItem
  341. ****************************************************************************}
  342. constructor TLinkedListItem.Create;
  343. begin
  344. Previous:=nil;
  345. Next:=nil;
  346. end;
  347. destructor TLinkedListItem.Destroy;
  348. begin
  349. end;
  350. function TLinkedListItem.GetCopy:TLinkedListItem;
  351. var
  352. p : TLinkedListItem;
  353. l : integer;
  354. begin
  355. p:=TLinkedListItemClass(ClassType).Create;
  356. l:=InstanceSize;
  357. Move(pointer(self)^,pointer(p)^,l);
  358. Result:=p;
  359. end;
  360. {****************************************************************************
  361. TLinkedList
  362. ****************************************************************************}
  363. constructor TLinkedList.Create;
  364. begin
  365. FFirst:=nil;
  366. Flast:=nil;
  367. FCount:=0;
  368. end;
  369. destructor TLinkedList.destroy;
  370. begin
  371. Clear;
  372. end;
  373. function TLinkedList.empty:boolean;
  374. begin
  375. Empty:=(FFirst=nil);
  376. end;
  377. procedure TLinkedList.Insert(Item:TLinkedListItem);
  378. begin
  379. if FFirst=nil then
  380. begin
  381. FLast:=Item;
  382. Item.Previous:=nil;
  383. Item.Next:=nil;
  384. end
  385. else
  386. begin
  387. FFirst.Previous:=Item;
  388. Item.Previous:=nil;
  389. Item.Next:=FFirst;
  390. end;
  391. FFirst:=Item;
  392. inc(FCount);
  393. end;
  394. procedure TLinkedList.Concat(Item:TLinkedListItem);
  395. begin
  396. if FFirst=nil then
  397. begin
  398. FFirst:=Item;
  399. Item.Previous:=nil;
  400. Item.Next:=nil;
  401. end
  402. else
  403. begin
  404. Flast.Next:=Item;
  405. Item.Previous:=Flast;
  406. Item.Next:=nil;
  407. end;
  408. Flast:=Item;
  409. inc(FCount);
  410. end;
  411. procedure TLinkedList.remove(Item:TLinkedListItem);
  412. begin
  413. if Item=nil then
  414. exit;
  415. if (FFirst=Item) and (Flast=Item) then
  416. begin
  417. FFirst:=nil;
  418. Flast:=nil;
  419. end
  420. else if FFirst=Item then
  421. begin
  422. FFirst:=Item.Next;
  423. if assigned(FFirst) then
  424. FFirst.Previous:=nil;
  425. end
  426. else if Flast=Item then
  427. begin
  428. Flast:=Flast.Previous;
  429. if assigned(Flast) then
  430. Flast.Next:=nil;
  431. end
  432. else
  433. begin
  434. Item.Previous.Next:=Item.Next;
  435. Item.Next.Previous:=Item.Previous;
  436. end;
  437. Item.Next:=nil;
  438. Item.Previous:=nil;
  439. dec(FCount);
  440. end;
  441. procedure TLinkedList.clear;
  442. var
  443. NewNode : TLinkedListItem;
  444. begin
  445. NewNode:=FFirst;
  446. while assigned(NewNode) do
  447. begin
  448. FFirst:=NewNode.Next;
  449. NewNode.Free;
  450. NewNode:=FFirst;
  451. end;
  452. FLast:=nil;
  453. FFirst:=nil;
  454. FCount:=0;
  455. end;
  456. function TLinkedList.GetFirst:TLinkedListItem;
  457. begin
  458. if FFirst=nil then
  459. GetFirst:=nil
  460. else
  461. begin
  462. GetFirst:=FFirst;
  463. if FFirst=FLast then
  464. FLast:=nil;
  465. FFirst:=FFirst.Next;
  466. dec(FCount);
  467. end;
  468. end;
  469. function TLinkedList.GetLast:TLinkedListItem;
  470. begin
  471. if FLast=nil then
  472. Getlast:=nil
  473. else
  474. begin
  475. Getlast:=FLast;
  476. if FLast=FFirst then
  477. FFirst:=nil;
  478. FLast:=FLast.Previous;
  479. dec(FCount);
  480. end;
  481. end;
  482. procedure TLinkedList.insertList(p : TLinkedList);
  483. begin
  484. { empty List ? }
  485. if (p.FFirst=nil) then
  486. exit;
  487. p.Flast.Next:=FFirst;
  488. { we have a double Linked List }
  489. if assigned(FFirst) then
  490. FFirst.Previous:=p.Flast;
  491. FFirst:=p.FFirst;
  492. if (FLast=nil) then
  493. Flast:=p.Flast;
  494. { p becomes empty }
  495. p.FFirst:=nil;
  496. p.Flast:=nil;
  497. end;
  498. procedure TLinkedList.concatList(p : TLinkedList);
  499. begin
  500. if (p.FFirst=nil) then
  501. exit;
  502. if FFirst=nil then
  503. FFirst:=p.FFirst
  504. else
  505. begin
  506. FLast.Next:=p.FFirst;
  507. p.FFirst.Previous:=Flast;
  508. end;
  509. Flast:=p.Flast;
  510. { make p empty }
  511. p.Flast:=nil;
  512. p.FFirst:=nil;
  513. end;
  514. procedure TLinkedList.insertListcopy(p : TLinkedList);
  515. var
  516. NewNode,NewNode2 : TLinkedListItem;
  517. begin
  518. NewNode:=p.First;
  519. while assigned(NewNode) do
  520. begin
  521. NewNode2:=NewNode.Getcopy;
  522. if assigned(NewNode2) then
  523. Insert(NewNode2);
  524. NewNode:=NewNode.Next;
  525. end;
  526. end;
  527. procedure TLinkedList.concatListcopy(p : TLinkedList);
  528. var
  529. NewNode,NewNode2 : TLinkedListItem;
  530. begin
  531. NewNode:=p.First;
  532. while assigned(NewNode) do
  533. begin
  534. NewNode2:=NewNode.Getcopy;
  535. if assigned(NewNode2) then
  536. Concat(NewNode2);
  537. NewNode:=NewNode.Next;
  538. end;
  539. end;
  540. {****************************************************************************
  541. TStringListItem
  542. ****************************************************************************}
  543. constructor TStringListItem.Create(const s:string);
  544. begin
  545. inherited Create;
  546. FPStr:=stringdup(s);
  547. end;
  548. destructor TStringListItem.Destroy;
  549. begin
  550. stringdispose(FPStr);
  551. end;
  552. function TStringListItem.Str:string;
  553. begin
  554. Str:=FPStr^;
  555. end;
  556. function TStringListItem.GetCopy:TLinkedListItem;
  557. begin
  558. Result:=(inherited GetCopy);
  559. TStringListItem(Result).FPStr:=stringdup(FPstr^);
  560. end;
  561. {****************************************************************************
  562. TSTRINGList
  563. ****************************************************************************}
  564. constructor tstringList.Create;
  565. begin
  566. inherited Create;
  567. FDoubles:=true;
  568. end;
  569. constructor tstringList.Create_no_double;
  570. begin
  571. inherited Create;
  572. FDoubles:=false;
  573. end;
  574. procedure tstringList.insert(const s : string);
  575. begin
  576. if (s='') or
  577. ((not FDoubles) and (find(s)<>nil)) then
  578. exit;
  579. inherited insert(tstringListItem.create(s));
  580. end;
  581. procedure tstringList.concat(const s : string);
  582. begin
  583. if (s='') or
  584. ((not FDoubles) and (find(s)<>nil)) then
  585. exit;
  586. inherited concat(tstringListItem.create(s));
  587. end;
  588. procedure tstringList.remove(const s : string);
  589. var
  590. p : tstringListItem;
  591. begin
  592. if s='' then
  593. exit;
  594. p:=find(s);
  595. if assigned(p) then
  596. inherited Remove(p);
  597. end;
  598. function tstringList.GetFirst : string;
  599. var
  600. p : tstringListItem;
  601. begin
  602. p:=tstringListItem(inherited GetFirst);
  603. if p=nil then
  604. GetFirst:=''
  605. else
  606. begin
  607. GetFirst:=p.FPStr^;
  608. p.free;
  609. end;
  610. end;
  611. function tstringList.Getlast : string;
  612. var
  613. p : tstringListItem;
  614. begin
  615. p:=tstringListItem(inherited Getlast);
  616. if p=nil then
  617. Getlast:=''
  618. else
  619. begin
  620. Getlast:=p.FPStr^;
  621. p.free;
  622. end;
  623. end;
  624. function tstringList.find(const s:string):TstringListItem;
  625. var
  626. NewNode : tstringListItem;
  627. begin
  628. find:=nil;
  629. if s='' then
  630. exit;
  631. NewNode:=tstringListItem(FFirst);
  632. while assigned(NewNode) do
  633. begin
  634. if NewNode.FPStr^=s then
  635. begin
  636. find:=NewNode;
  637. exit;
  638. end;
  639. NewNode:=tstringListItem(NewNode.Next);
  640. end;
  641. end;
  642. procedure TStringList.InsertItem(item:TStringListItem);
  643. begin
  644. inherited Insert(item);
  645. end;
  646. procedure TStringList.ConcatItem(item:TStringListItem);
  647. begin
  648. inherited Concat(item);
  649. end;
  650. {$ifdef OLD}
  651. {****************************************************************************
  652. Tnamedindexobject
  653. ****************************************************************************}
  654. constructor Tnamedindexobject.init;
  655. begin
  656. { index }
  657. indexnr:=-1;
  658. indexNext:=nil;
  659. { dictionary }
  660. left:=nil;
  661. right:=nil;
  662. _name:=nil;
  663. speedvalue:=-1;
  664. { List }
  665. ListNext:=nil;
  666. end;
  667. constructor Tnamedindexobject.initname(const n:string);
  668. begin
  669. { index }
  670. indexnr:=-1;
  671. indexNext:=nil;
  672. { dictionary }
  673. left:=nil;
  674. right:=nil;
  675. speedvalue:=-1;
  676. _name:=stringdup(n);
  677. { List }
  678. ListNext:=nil;
  679. end;
  680. destructor Tnamedindexobject.done;
  681. begin
  682. stringdispose(_name);
  683. end;
  684. procedure Tnamedindexobject.setname(const n:string);
  685. begin
  686. if speedvalue=-1 then
  687. begin
  688. if assigned(_name) then
  689. stringdispose(_name);
  690. _name:=stringdup(n);
  691. end;
  692. end;
  693. function Tnamedindexobject.name:string;
  694. begin
  695. if assigned(_name) then
  696. name:=_name^
  697. else
  698. name:='';
  699. end;
  700. {****************************************************************************
  701. TDICTIONARY
  702. ****************************************************************************}
  703. constructor Tdictionary.init;
  704. begin
  705. root:=nil;
  706. hasharray:=nil;
  707. noclear:=false;
  708. replace_existing:=false;
  709. end;
  710. procedure Tdictionary.usehash;
  711. begin
  712. if not(assigned(root)) and
  713. not(assigned(hasharray)) then
  714. begin
  715. New(hasharray);
  716. fillchar(hasharray^,sizeof(hasharray^),0);
  717. end;
  718. end;
  719. destructor Tdictionary.done;
  720. begin
  721. if not noclear then
  722. clear;
  723. if assigned(hasharray) then
  724. dispose(hasharray);
  725. end;
  726. procedure Tdictionary.cleartree(obj:Pnamedindexobject);
  727. begin
  728. if assigned(obj^.left) then
  729. cleartree(obj^.left);
  730. if assigned(obj^.right) then
  731. cleartree(obj^.right);
  732. dispose(obj,done);
  733. obj:=nil;
  734. end;
  735. procedure Tdictionary.clear;
  736. var
  737. w : integer;
  738. begin
  739. if assigned(root) then
  740. cleartree(root);
  741. if assigned(hasharray) then
  742. for w:=-hasharraysize to hasharraysize do
  743. if assigned(hasharray^[w]) then
  744. cleartree(hasharray^[w]);
  745. end;
  746. function Tdictionary.delete(const s:string):Pnamedindexobject;
  747. var p,speedvalue:integer;
  748. n:Pnamedindexobject;
  749. procedure insert_right_bottom(var root,Atree:Pnamedindexobject);
  750. begin
  751. while root^.right<>nil do
  752. root:=root^.right;
  753. root^.right:=Atree;
  754. end;
  755. function delete_from_tree(root:Pnamedindexobject):Pnamedindexobject;
  756. type leftright=(left,right);
  757. var lr:leftright;
  758. oldroot:Pnamedindexobject;
  759. begin
  760. oldroot:=nil;
  761. while (root<>nil) and (root^.speedvalue<>speedvalue) do
  762. begin
  763. oldroot:=root;
  764. if speedvalue<root^.speedvalue then
  765. begin
  766. root:=root^.right;
  767. lr:=right;
  768. end
  769. else
  770. begin
  771. root:=root^.left;
  772. lr:=left;
  773. end;
  774. end;
  775. while (root<>nil) and (root^._name^<>s) do
  776. begin
  777. oldroot:=root;
  778. if s<root^._name^ then
  779. begin
  780. root:=root^.right;
  781. lr:=right;
  782. end
  783. else
  784. begin
  785. root:=root^.left;
  786. lr:=left;
  787. end;
  788. end;
  789. if root^.left<>nil then
  790. begin
  791. {Now the Node pointing to root must point to the left
  792. subtree of root. The right subtree of root must be
  793. connected to the right bottom of the left subtree.}
  794. if lr=left then
  795. oldroot^.left:=root^.left
  796. else
  797. oldroot^.right:=root^.left;
  798. if root^.right<>nil then
  799. insert_right_bottom(root^.left,root^.right);
  800. end
  801. else
  802. {There is no left subtree. So we can just replace the Node to
  803. delete with the right subtree.}
  804. if lr=left then
  805. oldroot^.left:=root^.right
  806. else
  807. oldroot^.right:=root^.right;
  808. delete_from_tree:=root;
  809. end;
  810. begin
  811. speedvalue:=Getspeedvalue(s);
  812. n:=root;
  813. if assigned(hasharray) then
  814. begin
  815. {First, check if the Node to delete directly located under
  816. the hasharray.}
  817. p:=speedvalue mod hasharraysize;
  818. n:=hasharray^[p];
  819. if (n<>nil) and (n^.speedvalue=speedvalue) and
  820. (n^._name^=s) then
  821. begin
  822. {The Node to delete is directly located under the
  823. hasharray. Make the hasharray point to the left
  824. subtree of the Node and place the right subtree on
  825. the right-bottom of the left subtree.}
  826. if n^.left<>nil then
  827. begin
  828. hasharray^[p]:=n^.left;
  829. if n^.right<>nil then
  830. insert_right_bottom(n^.left,n^.right);
  831. end
  832. else
  833. hasharray^[p]:=n^.right;
  834. delete:=n;
  835. exit;
  836. end;
  837. end
  838. else
  839. begin
  840. {First check if the Node to delete is the root.}
  841. if (root<>nil) and (n^.speedvalue=speedvalue)
  842. and (n^._name^=s) then
  843. begin
  844. if n^.left<>nil then
  845. begin
  846. root:=n^.left;
  847. if n^.right<>nil then
  848. insert_right_bottom(n^.left,n^.right);
  849. end
  850. else
  851. root:=n^.right;
  852. delete:=n;
  853. exit;
  854. end;
  855. end;
  856. delete:=delete_from_tree(n);
  857. end;
  858. function Tdictionary.empty:boolean;
  859. var
  860. w : integer;
  861. begin
  862. if assigned(hasharray) then
  863. begin
  864. empty:=false;
  865. for w:=-hasharraysize to hasharraysize do
  866. if assigned(hasharray^[w]) then
  867. exit;
  868. empty:=true;
  869. end
  870. else
  871. empty:=(root=nil);
  872. end;
  873. procedure Tdictionary.foreach(proc2call:Tnamedindexcallback);
  874. procedure a(p:Pnamedindexobject);
  875. begin
  876. proc2call(p);
  877. if assigned(p^.left) then
  878. a(p^.left);
  879. if assigned(p^.right) then
  880. a(p^.right);
  881. end;
  882. var
  883. i : integer;
  884. begin
  885. if assigned(hasharray) then
  886. begin
  887. for i:=-hasharraysize to hasharraysize do
  888. if assigned(hasharray^[i]) then
  889. a(hasharray^[i]);
  890. end
  891. else
  892. if assigned(root) then
  893. a(root);
  894. end;
  895. function Tdictionary.insert(obj:Pnamedindexobject):Pnamedindexobject;
  896. begin
  897. obj^.speedvalue:=Getspeedvalue(obj^._name^);
  898. if assigned(hasharray) then
  899. insert:=insertNode(obj,hasharray^[obj^.speedvalue mod hasharraysize])
  900. else
  901. insert:=insertNode(obj,root);
  902. end;
  903. function tdictionary.insertNode(NewNode:Pnamedindexobject;var currNode:Pnamedindexobject):Pnamedindexobject;
  904. begin
  905. if currNode=nil then
  906. begin
  907. currNode:=NewNode;
  908. insertNode:=NewNode;
  909. end
  910. { First check speedvalue, to allow a fast insert }
  911. else
  912. if currNode^.speedvalue>NewNode^.speedvalue then
  913. insertNode:=insertNode(NewNode,currNode^.right)
  914. else
  915. if currNode^.speedvalue<NewNode^.speedvalue then
  916. insertNode:=insertNode(NewNode,currNode^.left)
  917. else
  918. begin
  919. if currNode^._name^>NewNode^._name^ then
  920. insertNode:=insertNode(NewNode,currNode^.right)
  921. else
  922. if currNode^._name^<NewNode^._name^ then
  923. insertNode:=insertNode(NewNode,currNode^.left)
  924. else
  925. begin
  926. if replace_existing and
  927. assigned(currNode) then
  928. begin
  929. NewNode^.left:=currNode^.left;
  930. NewNode^.right:=currNode^.right;
  931. currNode:=NewNode;
  932. insertNode:=NewNode;
  933. end
  934. else
  935. insertNode:=currNode;
  936. end;
  937. end;
  938. end;
  939. procedure tdictionary.inserttree(currtree,currroot:Pnamedindexobject);
  940. begin
  941. if assigned(currtree) then
  942. begin
  943. inserttree(currtree^.left,currroot);
  944. inserttree(currtree^.right,currroot);
  945. currtree^.right:=nil;
  946. currtree^.left:=nil;
  947. insertNode(currtree,currroot);
  948. end;
  949. end;
  950. function tdictionary.rename(const olds,News : string):Pnamedindexobject;
  951. var
  952. spdval : integer;
  953. lasthp,
  954. hp,hp2,hp3 : Pnamedindexobject;
  955. begin
  956. spdval:=Getspeedvalue(olds);
  957. if assigned(hasharray) then
  958. hp:=hasharray^[spdval mod hasharraysize]
  959. else
  960. hp:=root;
  961. lasthp:=nil;
  962. while assigned(hp) do
  963. begin
  964. if spdval>hp^.speedvalue then
  965. begin
  966. lasthp:=hp;
  967. hp:=hp^.left
  968. end
  969. else
  970. if spdval<hp^.speedvalue then
  971. begin
  972. lasthp:=hp;
  973. hp:=hp^.right
  974. end
  975. else
  976. begin
  977. if (hp^.name=olds) then
  978. begin
  979. { Get in hp2 the replacer for the root or hasharr }
  980. hp2:=hp^.left;
  981. hp3:=hp^.right;
  982. if not assigned(hp2) then
  983. begin
  984. hp2:=hp^.right;
  985. hp3:=hp^.left;
  986. end;
  987. { remove entry from the tree }
  988. if assigned(lasthp) then
  989. begin
  990. if lasthp^.left=hp then
  991. lasthp^.left:=hp2
  992. else
  993. lasthp^.right:=hp2;
  994. end
  995. else
  996. begin
  997. if assigned(hasharray) then
  998. hasharray^[spdval mod hasharraysize]:=hp2
  999. else
  1000. root:=hp2;
  1001. end;
  1002. { reinsert the hp3 in the tree from hp2 }
  1003. inserttree(hp3,hp2);
  1004. { reset Node with New values }
  1005. stringdispose(hp^._name);
  1006. hp^._name:=stringdup(News);
  1007. hp^.speedvalue:=Getspeedvalue(News);
  1008. hp^.left:=nil;
  1009. hp^.right:=nil;
  1010. { reinsert }
  1011. if assigned(hasharray) then
  1012. rename:=insertNode(hp,hasharray^[hp^.speedvalue mod hasharraysize])
  1013. else
  1014. rename:=insertNode(hp,root);
  1015. exit;
  1016. end
  1017. else
  1018. if olds>hp^.name then
  1019. begin
  1020. lasthp:=hp;
  1021. hp:=hp^.left
  1022. end
  1023. else
  1024. begin
  1025. lasthp:=hp;
  1026. hp:=hp^.right;
  1027. end;
  1028. end;
  1029. end;
  1030. end;
  1031. function Tdictionary.search(const s:string):Pnamedindexobject;
  1032. begin
  1033. search:=speedsearch(s,Getspeedvalue(s));
  1034. end;
  1035. function Tdictionary.speedsearch(const s:string;speedvalue:integer):Pnamedindexobject;
  1036. var
  1037. NewNode:Pnamedindexobject;
  1038. begin
  1039. if assigned(hasharray) then
  1040. NewNode:=hasharray^[speedvalue mod hasharraysize]
  1041. else
  1042. NewNode:=root;
  1043. while assigned(NewNode) do
  1044. begin
  1045. if speedvalue>NewNode^.speedvalue then
  1046. NewNode:=NewNode^.left
  1047. else
  1048. if speedvalue<NewNode^.speedvalue then
  1049. NewNode:=NewNode^.right
  1050. else
  1051. begin
  1052. if (NewNode^._name^=s) then
  1053. begin
  1054. speedsearch:=NewNode;
  1055. exit;
  1056. end
  1057. else
  1058. if s>NewNode^._name^ then
  1059. NewNode:=NewNode^.left
  1060. else
  1061. NewNode:=NewNode^.right;
  1062. end;
  1063. end;
  1064. speedsearch:=nil;
  1065. end;
  1066. {****************************************************************************
  1067. tsingleList
  1068. ****************************************************************************}
  1069. constructor tsingleList.init;
  1070. begin
  1071. First:=nil;
  1072. last:=nil;
  1073. end;
  1074. destructor tsingleList.done;
  1075. begin
  1076. end;
  1077. procedure tsingleList.reset;
  1078. begin
  1079. First:=nil;
  1080. last:=nil;
  1081. end;
  1082. procedure tsingleList.clear;
  1083. var
  1084. hp,hp2 : pnamedindexobject;
  1085. begin
  1086. hp:=First;
  1087. while assigned(hp) do
  1088. begin
  1089. hp2:=hp;
  1090. hp:=hp^.ListNext;
  1091. dispose(hp2,done);
  1092. end;
  1093. First:=nil;
  1094. last:=nil;
  1095. end;
  1096. procedure tsingleList.insert(p:Pnamedindexobject);
  1097. begin
  1098. if not assigned(First) then
  1099. First:=p
  1100. else
  1101. last^.ListNext:=p;
  1102. last:=p;
  1103. p^.ListNext:=nil;
  1104. end;
  1105. {****************************************************************************
  1106. tindexarray
  1107. ****************************************************************************}
  1108. constructor tindexarray.create(Agrowsize:integer);
  1109. begin
  1110. growsize:=Agrowsize;
  1111. size:=0;
  1112. count:=0;
  1113. data:=nil;
  1114. First:=nil;
  1115. noclear:=false;
  1116. end;
  1117. destructor tindexarray.destroy;
  1118. begin
  1119. if assigned(data) then
  1120. begin
  1121. if not noclear then
  1122. clear;
  1123. freemem(data);
  1124. data:=nil;
  1125. end;
  1126. end;
  1127. function tindexarray.search(nr:integer):Pnamedindexobject;
  1128. begin
  1129. if nr<=count then
  1130. search:=data^[nr]
  1131. else
  1132. search:=nil;
  1133. end;
  1134. procedure tindexarray.clear;
  1135. var
  1136. i : integer;
  1137. begin
  1138. for i:=1 to count do
  1139. if assigned(data^[i]) then
  1140. begin
  1141. dispose(data^[i],done);
  1142. data^[i]:=nil;
  1143. end;
  1144. count:=0;
  1145. First:=nil;
  1146. end;
  1147. procedure tindexarray.foreach(proc2call : Tnamedindexcallback);
  1148. var
  1149. i : integer;
  1150. begin
  1151. for i:=1 to count do
  1152. if assigned(data^[i]) then
  1153. proc2call(data^[i]);
  1154. end;
  1155. procedure tindexarray.grow(gsize:integer);
  1156. var
  1157. osize : integer;
  1158. begin
  1159. osize:=size;
  1160. inc(size,gsize);
  1161. reallocmem(data,size*4);
  1162. fillchar(data^[osize+1],gsize*4,0);
  1163. end;
  1164. procedure tindexarray.deleteindex(p:Pnamedindexobject);
  1165. var
  1166. i : integer;
  1167. begin
  1168. i:=p^.indexnr;
  1169. { update counter }
  1170. if i=count then
  1171. dec(count);
  1172. { update Linked List }
  1173. while (i>0) do
  1174. begin
  1175. dec(i);
  1176. if (i>0) and assigned(data^[i]) then
  1177. begin
  1178. data^[i]^.indexNext:=data^[p^.indexnr]^.indexNext;
  1179. break;
  1180. end;
  1181. end;
  1182. if i=0 then
  1183. First:=p^.indexNext;
  1184. data^[p^.indexnr]:=nil;
  1185. { clear entry }
  1186. p^.indexnr:=-1;
  1187. p^.indexNext:=nil;
  1188. end;
  1189. procedure tindexarray.delete(var p:Pnamedindexobject);
  1190. begin
  1191. deleteindex(p);
  1192. dispose(p,done);
  1193. p:=nil;
  1194. end;
  1195. procedure tindexarray.insert(p:Pnamedindexobject);
  1196. var
  1197. i : integer;
  1198. begin
  1199. if p^.indexnr=-1 then
  1200. begin
  1201. inc(count);
  1202. p^.indexnr:=count;
  1203. end;
  1204. if p^.indexnr>count then
  1205. count:=p^.indexnr;
  1206. if count>size then
  1207. grow(((count div growsize)+1)*growsize);
  1208. Assert(not assigned(data^[p^.indexnr]) or (p=data^[p^.indexnr]));
  1209. data^[p^.indexnr]:=p;
  1210. { update Linked List backward }
  1211. i:=p^.indexnr;
  1212. while (i>0) do
  1213. begin
  1214. dec(i);
  1215. if (i>0) and assigned(data^[i]) then
  1216. begin
  1217. data^[i]^.indexNext:=p;
  1218. break;
  1219. end;
  1220. end;
  1221. if i=0 then
  1222. First:=p;
  1223. { update Linked List forward }
  1224. i:=p^.indexnr;
  1225. while (i<=count) do
  1226. begin
  1227. inc(i);
  1228. if (i<=count) and assigned(data^[i]) then
  1229. begin
  1230. p^.indexNext:=data^[i];
  1231. exit;
  1232. end;
  1233. end;
  1234. if i>count then
  1235. p^.indexNext:=nil;
  1236. end;
  1237. {$endif OLD}
  1238. {****************************************************************************
  1239. tdynamicarray
  1240. ****************************************************************************}
  1241. constructor tdynamicarray.create(Ablocksize:integer);
  1242. begin
  1243. FPosn:=0;
  1244. FPosnblock:=nil;
  1245. FFirstblock:=nil;
  1246. FLastblock:=nil;
  1247. Fblocksize:=Ablocksize;
  1248. grow;
  1249. end;
  1250. destructor tdynamicarray.destroy;
  1251. var
  1252. hp : pdynamicblock;
  1253. begin
  1254. while assigned(FFirstblock) do
  1255. begin
  1256. hp:=FFirstblock;
  1257. FFirstblock:=FFirstblock^.Next;
  1258. freemem(hp,blocksize+dynamicblockbasesize);
  1259. end;
  1260. end;
  1261. function tdynamicarray.size:integer;
  1262. begin
  1263. if assigned(FLastblock) then
  1264. size:=FLastblock^.pos+FLastblock^.used
  1265. else
  1266. size:=0;
  1267. end;
  1268. procedure tdynamicarray.grow;
  1269. var
  1270. nblock : pdynamicblock;
  1271. begin
  1272. Getmem(nblock,blocksize+dynamicblockbasesize);
  1273. if not assigned(FFirstblock) then
  1274. begin
  1275. FFirstblock:=nblock;
  1276. FPosnblock:=nblock;
  1277. nblock^.pos:=0;
  1278. end
  1279. else
  1280. begin
  1281. FLastblock^.Next:=nblock;
  1282. nblock^.pos:=FLastblock^.pos+FLastblock^.used;
  1283. end;
  1284. nblock^.used:=0;
  1285. nblock^.Next:=nil;
  1286. fillchar(nblock^.data,blocksize,0);
  1287. FLastblock:=nblock;
  1288. end;
  1289. procedure tdynamicarray.align(i:integer);
  1290. var
  1291. j : integer;
  1292. begin
  1293. j:=(FPosn mod i);
  1294. if j<>0 then
  1295. begin
  1296. j:=i-j;
  1297. if FPosnblock^.used+j>blocksize then
  1298. begin
  1299. dec(j,blocksize-FPosnblock^.used);
  1300. FPosnblock^.used:=blocksize;
  1301. grow;
  1302. FPosnblock:=FLastblock;
  1303. end;
  1304. inc(FPosnblock^.used,j);
  1305. inc(FPosn,j);
  1306. end;
  1307. end;
  1308. procedure tdynamicarray.seek(i:integer);
  1309. begin
  1310. if (i<FPosnblock^.pos) or (i>FPosnblock^.pos+blocksize) then
  1311. begin
  1312. { set FPosnblock correct if the size is bigger then
  1313. the current block }
  1314. if FPosnblock^.pos>i then
  1315. FPosnblock:=FFirstblock;
  1316. while assigned(FPosnblock) do
  1317. begin
  1318. if FPosnblock^.pos+blocksize>i then
  1319. break;
  1320. FPosnblock:=FPosnblock^.Next;
  1321. end;
  1322. { not found ? then increase blocks }
  1323. if not assigned(FPosnblock) then
  1324. begin
  1325. { the current FLastblock is now also fully used }
  1326. FLastblock^.used:=blocksize;
  1327. repeat
  1328. grow;
  1329. FPosnblock:=FLastblock;
  1330. until FPosnblock^.pos+blocksize>=i;
  1331. end;
  1332. end;
  1333. FPosn:=i;
  1334. if FPosn mod blocksize>FPosnblock^.used then
  1335. FPosnblock^.used:=FPosn mod blocksize;
  1336. end;
  1337. procedure tdynamicarray.write(const d;len:integer);
  1338. var
  1339. p : pchar;
  1340. i,j : integer;
  1341. begin
  1342. p:=pchar(@d);
  1343. while (len>0) do
  1344. begin
  1345. i:=FPosn mod blocksize;
  1346. if i+len>=blocksize then
  1347. begin
  1348. j:=blocksize-i;
  1349. move(p^,FPosnblock^.data[i],j);
  1350. inc(p,j);
  1351. inc(FPosn,j);
  1352. dec(len,j);
  1353. FPosnblock^.used:=blocksize;
  1354. if assigned(FPosnblock^.Next) then
  1355. FPosnblock:=FPosnblock^.Next
  1356. else
  1357. begin
  1358. grow;
  1359. FPosnblock:=FLastblock;
  1360. end;
  1361. end
  1362. else
  1363. begin
  1364. move(p^,FPosnblock^.data[i],len);
  1365. inc(p,len);
  1366. inc(FPosn,len);
  1367. i:=FPosn mod blocksize;
  1368. if i>FPosnblock^.used then
  1369. FPosnblock^.used:=i;
  1370. len:=0;
  1371. end;
  1372. end;
  1373. end;
  1374. procedure tdynamicarray.writestr(const s:string);
  1375. begin
  1376. write(s[1],length(s));
  1377. end;
  1378. function tdynamicarray.read(var d;len:integer):integer;
  1379. var
  1380. p : pchar;
  1381. i,j,res : integer;
  1382. begin
  1383. res:=0;
  1384. p:=pchar(@d);
  1385. while (len>0) do
  1386. begin
  1387. i:=FPosn mod blocksize;
  1388. if i+len>=FPosnblock^.used then
  1389. begin
  1390. j:=FPosnblock^.used-i;
  1391. move(FPosnblock^.data[i],p^,j);
  1392. inc(p,j);
  1393. inc(FPosn,j);
  1394. inc(res,j);
  1395. dec(len,j);
  1396. if assigned(FPosnblock^.Next) then
  1397. FPosnblock:=FPosnblock^.Next
  1398. else
  1399. break;
  1400. end
  1401. else
  1402. begin
  1403. move(FPosnblock^.data[i],p^,len);
  1404. inc(p,len);
  1405. inc(FPosn,len);
  1406. inc(res,len);
  1407. len:=0;
  1408. end;
  1409. end;
  1410. read:=res;
  1411. end;
  1412. procedure tdynamicarray.readstream(f:TCStream);
  1413. var
  1414. i,left : integer;
  1415. begin
  1416. repeat
  1417. left:=blocksize-FPosnblock^.used;
  1418. i:=f.Read(FPosnblock^.data[FPosnblock^.used],left);
  1419. inc(FPosnblock^.used,i);
  1420. if FPosnblock^.used=blocksize then
  1421. begin
  1422. if assigned(FPosnblock^.Next) then
  1423. FPosnblock:=FPosnblock^.Next
  1424. else
  1425. begin
  1426. grow;
  1427. FPosnblock:=FLastblock;
  1428. end;
  1429. end;
  1430. until (i<left);
  1431. end;
  1432. procedure tdynamicarray.writestream(f:TCStream);
  1433. var
  1434. hp : pdynamicblock;
  1435. begin
  1436. hp:=FFirstblock;
  1437. while assigned(hp) do
  1438. begin
  1439. f.Write(hp^.data,hp^.used);
  1440. hp:=hp^.Next;
  1441. end;
  1442. end;
  1443. end.
  1444. {
  1445. $Log$
  1446. Revision 1.2 2000-12-25 00:07:25 peter
  1447. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1448. tlinkedlist objects)
  1449. Revision 1.1 2000/12/24 12:25:31 peter
  1450. + cstreams unit
  1451. * dynamicarray object to class
  1452. }