home *** CD-ROM | disk | FTP | other *** search
- {+--------------------------------------------------------------------------+
- | Created: 12.97
- | Author: Martin Waldenburg
- | Copyright 1997, all rights reserved.
- | Description: Demo for TmSor.
- | Version: 1.0
- | Status FreeWare
- | It's provided as is, without a warranty of any kind.
- | You use it at your own risc.
- | E-Mail me at Martin.Waldenburg@t-online.de
- +--------------------------------------------------------------------------+}
-
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, mwFixedRecSort, mwFastTime, mwCompFrom;
-
- type
- PDemoData=^TDemoData;
- TDemoData=record
- Data1: String[50];
- Data2: String[210];
- Data3: String[237];
- end;
-
- TForm1=class(TForm)
- Button1: TButton;
- OpenDialog1: TOpenDialog;
- Time1: TmwFastTime;
- Edit1: TEdit;
- procedure Button1Click(Sender: TObject);
- private
- { Private-Deklarationen }
- public
- { Public-Deklarationen }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- function Compare(Item1, Item2: Pointer): Integer;
- begin
- Result:=CompareTextFrom(Item1, Item2, 2, 50);
-
- {Result:= CompareText(PDemoData(Item1)^.Data1, PDemoData(Item2)^.Data1);
- The same as above, more comfortable but slower.
- A typecast can cost lots of time.
- However, for large amounts of Records (Millions) Windows file buffering system
- will equalize this..}
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- var
- Sorter: TFixRecSort;
- begin
- if OpenDialog1.Execute then
- begin
- Time1.Start;
- Sorter:=TFixRecSort.Create(500);
- Sorter.Stable:=True;
- Sorter.Start(OpenDialog1.FileName, 'aSorTest.out', Compare);
- Time1.Stop;
- Edit1.Text:=Time1.ElapsedTime;
- Sorter.Free;
- end;
- end;
-
- end.
-
-