Ignore:
Timestamp:
Feb 8, 2012, 2:13:08 PM (13 years ago)
Author:
chronos
Message:
  • Modified: TGTree structure.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/NativeGenerics/Demo/UMainForm.pas

    r324 r326  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    99  ComCtrls, GenericList, GenericDictionary, GenericQueue, GenericStream,
    10   DateUtils, SpecializedList;
     10  DateUtils, GenericString, GenericTree;
    1111
    1212type
     
    1515
    1616  TMainForm = class(TForm)
    17     ButtonStreamByte: TButton;
     17    TreeButton: TButton;
     18    StreamByteButton: TButton;
    1819    ButtonBenchmarkDictionary: TButton;
    1920    ButtonBenchmarkListPointer: TButton;
    20     ButtonListObject: TButton;
     21    ListObjectButton: TButton;
    2122    ButtonBenchmarkListString: TButton;
    22     ButtonCharList: TButton;
    23     ButtonMatrixInteger: TButton;
    24     ButtonQueueInteger: TButton;
    25     ButtonDictionaryString: TButton;
    26     ButtonIntegerList: TButton;
    27     ButtonStringList: TButton;
     23    CharListButton: TButton;
     24    MatrixIntegerButton: TButton;
     25    QueueIntegerButton: TButton;
     26    DictionaryStringButton: TButton;
     27    IntegerListButton: TButton;
     28    StringListButton: TButton;
    2829    Label1: TLabel;
    2930    LabelTestName: TLabel;
     
    3233    procedure ButtonBenchmarkListPointerClick(Sender: TObject);
    3334    procedure ButtonBenchmarkListStringClick(Sender: TObject);
    34     procedure ButtonCharListClick(Sender: TObject);
    35     procedure ButtonDictionaryStringClick(Sender: TObject);
    36     procedure ButtonIntegerListClick(Sender: TObject);
    37     procedure ButtonMatrixIntegerClick(Sender: TObject);
    38     procedure ButtonListObjectClick(Sender: TObject);
    39     procedure ButtonQueueIntegerClick(Sender: TObject);
    40     procedure ButtonStreamByteClick(Sender: TObject);
    41     procedure ButtonStringListClick(Sender: TObject);
     35    procedure CharListButtonClick(Sender: TObject);
     36    procedure DictionaryStringButtonClick(Sender: TObject);
     37    procedure IntegerListButtonClick(Sender: TObject);
     38    procedure MatrixIntegerButtonClick(Sender: TObject);
     39    procedure ListObjectButtonClick(Sender: TObject);
     40    procedure QueueIntegerButtonClick(Sender: TObject);
     41    procedure StreamByteButtonClick(Sender: TObject);
     42    procedure StringListButtonClick(Sender: TObject);
    4243    procedure FormCreate(Sender: TObject);
    4344    procedure FormDestroy(Sender: TObject);
     45    procedure TreeButtonClick(Sender: TObject);
    4446  private
    4547  public
     
    6365end;
    6466
    65 procedure TMainForm.ButtonIntegerListClick(Sender: TObject);
     67procedure TMainForm.IntegerListButtonClick(Sender: TObject);
    6668var
    6769  List: TGList<Integer>;
     
    7072begin
    7173  ListViewOutput.Clear;
    72   LabelTestName.Caption := 'TListInteger test';
     74  LabelTestName.Caption := 'TGList<Integer> test';
    7375  List := TGList<Integer>.Create;
    7476  List2 := TGList<Integer>.Create;
     
    105107end;
    106108
    107 procedure TMainForm.ButtonMatrixIntegerClick(Sender: TObject);
     109procedure TMainForm.MatrixIntegerButtonClick(Sender: TObject);
    108110//var
    109111//  Matrix: TGMatrix<Integer, Integer, Integer>;
    110112begin
    111113  (*  ListViewOutput.Clear;
    112   LabelTestName.Caption := 'TMatrixInteger test';
     114  LabelTestName.Caption := 'TGMatrix<Integer> test';
    113115  Matrix := TGMatrix<Integer, Integer, Integer>.Create;
    114116  with Matrix do try
     
    133135end;
    134136
    135 procedure TMainForm.ButtonListObjectClick(Sender: TObject);
    136 //var
    137   //List: TListObject<TObject>;
    138   //I: Integer;
    139 begin
    140   (*ListViewOutput.Clear;
    141   LabelTestName.Caption := 'TListObject test';
    142   List := TGListObject<TObject>.Create;
     137procedure TMainForm.ListObjectButtonClick(Sender: TObject);
     138var
     139  List: TGObjectList<TObject>;
     140  I: Integer;
     141begin
     142  ListViewOutput.Clear;
     143  LabelTestName.Caption := 'TObjectList<TObject> test';
     144  List := TGObjectList<TObject>.Create;
    143145  with List do try
    144146    AddArray([TObject.Create, TObject.Create, TObject.Create, TObject.Create]);
     
    155157  finally
    156158    Free;
    157   end;*)
    158 end;
    159 
    160 procedure TMainForm.ButtonQueueIntegerClick(Sender: TObject);
     159  end;
     160end;
     161
     162procedure TMainForm.QueueIntegerButtonClick(Sender: TObject);
    161163var
    162164  Queue: TGQueue<Integer>;
    163165begin
    164166  ListViewOutput.Clear;
    165   LabelTestName.Caption := 'TQueueInteger test';
     167  LabelTestName.Caption := 'TGQueue<Integer> test';
    166168  Queue := TGQueue<Integer>.Create;
    167169  with Queue do try
     
    179181end;
    180182
    181 procedure TMainForm.ButtonStreamByteClick(Sender: TObject);
     183procedure TMainForm.StreamByteButtonClick(Sender: TObject);
    182184var
    183185  Stream: TGStream<Byte>;
     
    187189begin
    188190  ListViewOutput.Clear;
    189   LabelTestName.Caption := 'TStreamByte test';
     191  LabelTestName.Caption := 'TGStream<Byte> test';
    190192  Stream := TGStream<Byte>.Create;
    191193  with Stream do try
     
    221223end;
    222224
    223 procedure TMainForm.ButtonDictionaryStringClick(Sender: TObject);
     225procedure TMainForm.DictionaryStringButtonClick(Sender: TObject);
    224226//type
    225227//  TPairStringString = TGPair<string, string>;
     
    228230begin
    229231  ListViewOutput.Clear;
    230   LabelTestName.Caption := 'TDictionaryString test';
     232  LabelTestName.Caption := 'TGDictionary<string, string> test';
    231233  Dictionary := TGDictionary<string, string>.Create;
    232234  with Dictionary do try
     
    251253end;
    252254
    253 procedure TMainForm.ButtonCharListClick(Sender: TObject);
    254 var
    255   List: TListChar;
    256   List2: TListChar;
    257 begin
    258   ListViewOutput.Clear;
    259   LabelTestName.Caption := 'TListChar test';
    260   List := TListChar.Create;
    261   List2 := TListChar.Create;
     255procedure TMainForm.CharListButtonClick(Sender: TObject);
     256var
     257  List: TGString<Char>;
     258  List2: TGString<Char>;
     259begin
     260  ListViewOutput.Clear;
     261  LabelTestName.Caption := 'TGString<Char> test';
     262  List := TGString<Char>.Create;
     263  List2 := TGString<Char>.Create;
    262264  with List do try
    263265    AddArray([' ', ' ', 'A', 'b', 'c', 'd', ' ']);
     
    293295  SampleCount: Integer = 100000;
    294296begin
    295   LabelTestName.Caption := 'Generic specialized TListString vs. classic non-generic TStringList benchmark';
     297  LabelTestName.Caption := 'Generic specialized TGStringList<string> vs. classic non-generic TStringList benchmark';
    296298  ListViewOutput.Clear;
    297299  try
     
    441443  R: string;
    442444begin
    443   LabelTestName.Caption := 'Generic specialized TDictionaryStringString vs. classic non-generic TStringList benchmark';
     445  LabelTestName.Caption := 'Generic specialized TGDictionary<string,string> vs. classic non-generic TStringList benchmark';
    444446  ListViewOutput.Clear;
    445447  try
     
    537539  SampleCount: Integer = 100000;
    538540begin
    539   LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic TFPList benchmark';
     541  LabelTestName.Caption := 'Generic specialized TGObjectList<Object> vs. classic non-generic TFPList benchmark';
    540542  ListViewOutput.Clear;
    541543  try
     
    728730end;
    729731
    730 procedure TMainForm.ButtonStringListClick(Sender: TObject);
     732procedure TMainForm.StringListButtonClick(Sender: TObject);
    731733var
    732734  List: TGList<String>;
    733735begin
    734736  ListViewOutput.Clear;
    735   WriteOutput('TListString test');
     737  WriteOutput('TGList<string> test');
    736738  List := TGList<String>.Create;
    737739  with List do try
     
    759761end;
    760762
     763procedure TMainForm.TreeButtonClick(Sender: TObject);
     764var
     765  Tree: TGTree<string>;
     766  //Tree2: TGTree<string>;
     767  I: Integer;
     768begin
     769  {ListViewOutput.Clear;
     770  LabelTestName.Caption := 'TGTree<string> test';
     771  Tree := TGTree<Integer>.Create;
     772  Tree2 := TGTree<Integer>.Create;
     773  with Tree do try
     774(*    AddArray([10, 20, 30, 40]);
     775    WriteOutput('AddArray([10, 20, 30, 40])', Implode(',', IntToStr));
     776    Clear;
     777    WriteOutput('Clear', Implode(',', IntToStr));
     778    for I := 0 to 10 do Add(I);
     779    WriteOutput('for I := 0 to 10 do Add(I)', Implode(',', IntToStr));
     780    WriteOutput('Count', IntToStr(Count));
     781    Reverse;
     782    WriteOutput('Reverse', Implode(',', IntToStr));
     783    WriteOutput('First', IntToStr(First));
     784    WriteOutput('Last', IntToStr(Last));
     785    MoveItems(3, 2, 3);
     786    WriteOutput('MoveItems(3, 2, 3)', Implode(',', IntToStr));
     787    Insert(5, 11);
     788    WriteOutput('Insert(5, 11)', Implode(',', IntToStr));
     789    DeleteItems(0, 10);
     790    WriteOutput('Delete(0, 10)', Implode(',', IntToStr));
     791    List2.SetArray([1, 0]);
     792    WriteOutput('EqualTo([6, 11])', BoolToStr(EqualTo(List2)));
     793    List2.SetArray([2, 0]);
     794    WriteOutput('EqualTo([7, 11])', BoolToStr(EqualTo(List2)));
     795    InsertCount(0, 3);
     796    WriteOutput('InsertCount(0, 3)', Implode(',', IntToStr));
     797    Fill(0, 3, 9);
     798    WriteOutput('Fill(0, 3, 9)', Implode(',', IntToStr));*)
     799  finally
     800    Free;
     801    Tree2.Free;
     802  end;}
     803end;
     804
    761805procedure TMainForm.UpdateButtonState(Enabled: Boolean);
    762806begin
    763807  ButtonBenchmarkDictionary.Enabled := Enabled;
    764808  ButtonBenchmarkListString.Enabled := Enabled;
    765   ButtonCharList.Enabled := Enabled;
    766   ButtonDictionaryString.Enabled := Enabled;
    767   ButtonIntegerList.Enabled := Enabled;
    768   ButtonListObject.Enabled := Enabled;
    769   ButtonMatrixInteger.Enabled := Enabled;
    770   ButtonQueueInteger.Enabled := Enabled;
    771   ButtonStringList.Enabled := Enabled;
     809  CharListButton.Enabled := Enabled;
     810  DictionaryStringButton.Enabled := Enabled;
     811  IntegerListButton.Enabled := Enabled;
     812  ListObjectButton.Enabled := Enabled;
     813  MatrixIntegerButton.Enabled := Enabled;
     814  QueueIntegerButton.Enabled := Enabled;
     815  StringListButton.Enabled := Enabled;
    772816end;
    773817
Note: See TracChangeset for help on using the changeset viewer.