home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / arrays / generics / genlist / testheap.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-24  |  774 b   |  45 lines

  1. Program TestHeap;  {Test program for descendants of Linked Generic Heaps}
  2.  
  3. {Linked Heaps
  4.  incur an overhead penalty of 14 (+Elementsize) bytes for EACH ELEMENT!}
  5.  
  6. Uses L_Heaps,NodeSort;
  7.  
  8. Var
  9.   A : L_IntHeap;
  10.   B : L_IntHeap;
  11.   I : Integer;
  12.   J : Integer;
  13.  
  14. Begin
  15.  
  16.   Randomize;
  17.   A.Create;
  18.   B.Create;
  19.   A.Init;
  20.  
  21.   For I := 1 to 12 do
  22.     Begin
  23.       J := Random (10000);
  24.       WriteLn ('Sifting Up List Element ',I,' which is ',J:6);
  25.       A.SiftUp(J)
  26.    End;
  27.  
  28.   B.Copy (A);
  29.   A.Sort;
  30.  
  31.   For I := 1 to A.CurrentLength do
  32.     Begin
  33.       J := A.Retrieve (I);
  34.       Write ('Sorted Element ',I:3,' is ',J:6);
  35.       J := B.Retrieve (I);
  36.       WriteLn ('  Heaped Element was ',J:6)
  37.     End;
  38.  
  39.   A.Destroy;
  40.   B.Destroy;
  41.  
  42.   ReadLn;
  43. End.
  44.  
  45.