home *** CD-ROM | disk | FTP | other *** search
- Program TestHeap; {Test program for descendants of Linked Generic Heaps}
-
- {Linked Heaps
- incur an overhead penalty of 14 (+Elementsize) bytes for EACH ELEMENT!}
-
- Uses L_Heaps,NodeSort;
-
- Var
- A : L_IntHeap;
- B : L_IntHeap;
- I : Integer;
- J : Integer;
-
- Begin
-
- Randomize;
- A.Create;
- B.Create;
- A.Init;
-
- For I := 1 to 12 do
- Begin
- J := Random (10000);
- WriteLn ('Sifting Up List Element ',I,' which is ',J:6);
- A.SiftUp(J)
- End;
-
- B.Copy (A);
- A.Sort;
-
- For I := 1 to A.CurrentLength do
- Begin
- J := A.Retrieve (I);
- Write ('Sorted Element ',I:3,' is ',J:6);
- J := B.Retrieve (I);
- WriteLn (' Heaped Element was ',J:6)
- End;
-
- A.Destroy;
- B.Destroy;
-
- ReadLn;
- End.
-