home *** CD-ROM | disk | FTP | other *** search
- Program Test_ExtendedArray_Based_Heaps;
-
- Uses XHeaps,Crt;
-
- Const
- Num = 100000; {Compile to disk. Takes 18 hours, 23 minutes on my
- 6.44mhz 8088 XT-Clone.}
-
- {
- This ExtendedHeap exists in 11 lobes, each holding
- 9091 real numbers. 8 are always in memory, and 3
- are always on disk. It took 42 minutes to SiftUp
- all 100000 reals, which I consider very good. BUT,
- the first 9090 elements took 6 hours and 47 minutes
- to Sort out. The second 9091 took 4 hours and 48
- minutes, and the third took 3 hours and 17 minutes.
- The remaining 8 took only 3 hours and 31 minutes.
- This rather extreme example points out the inherent
- slowness encountered in the SiftDown operation,
- whenever even 1 Lobe must still reside on Disk, due
- to SiftDown's need to examine each Lobe for each pass.
-
- For serial applications (such as Stacks, or arrays
- which will always be accessed sequentially), the
- ExtendedArray should be very satisfactory even for
- ridiculously large applications. For Random access,
- something else will be preferable!
- }
-
- Var
- H : RealHeap;
- I : LongInt;
- R : Real;
-
- Begin
- ClrScr;
- Randomize;
-
- WriteLn (MemAvail,' Bytes Available before Initialization.');
-
- H.Create;
- H.Init(Num);
-
- WriteLn (MemAvail,' Bytes Available after Initialization.');
- WriteLn;
- WriteLn ('SORTING ',Num,' FLOATING POINT NUMBERS.');
-
- For I := 1 to Num do
- Begin
- R := Random;
- R := R*1000000;
- GoToXY (1,5);
- Write ('Sifting Up ',I,'th Element.');
- H.SiftUp (R,I)
- End;
-
- GoToXY (1,6);
- ClrEol;
- Write ('Sorting');
- H.Sort;
- WriteLn;
-
- { (* Commented off for Time-Test *)
-
- For I := 1 to Num do WriteLn (H.Retrieve(I):5:5,' was the ',I,'th Element');
-
- ReadLn;
-
- H.Destroy;
-
- }
-
- End.