Changeset 326 for Generics/NativeGenerics/Demo/UMainForm.pas
- Timestamp:
- Feb 8, 2012, 2:13:08 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/NativeGenerics/Demo/UMainForm.pas
r324 r326 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 ComCtrls, GenericList, GenericDictionary, GenericQueue, GenericStream, 10 DateUtils, SpecializedList;10 DateUtils, GenericString, GenericTree; 11 11 12 12 type … … 15 15 16 16 TMainForm = class(TForm) 17 ButtonStreamByte: TButton; 17 TreeButton: TButton; 18 StreamByteButton: TButton; 18 19 ButtonBenchmarkDictionary: TButton; 19 20 ButtonBenchmarkListPointer: TButton; 20 ButtonListObject: TButton;21 ListObjectButton: TButton; 21 22 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; 28 29 Label1: TLabel; 29 30 LabelTestName: TLabel; … … 32 33 procedure ButtonBenchmarkListPointerClick(Sender: TObject); 33 34 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); 42 43 procedure FormCreate(Sender: TObject); 43 44 procedure FormDestroy(Sender: TObject); 45 procedure TreeButtonClick(Sender: TObject); 44 46 private 45 47 public … … 63 65 end; 64 66 65 procedure TMainForm. ButtonIntegerListClick(Sender: TObject);67 procedure TMainForm.IntegerListButtonClick(Sender: TObject); 66 68 var 67 69 List: TGList<Integer>; … … 70 72 begin 71 73 ListViewOutput.Clear; 72 LabelTestName.Caption := 'T ListIntegertest';74 LabelTestName.Caption := 'TGList<Integer> test'; 73 75 List := TGList<Integer>.Create; 74 76 List2 := TGList<Integer>.Create; … … 105 107 end; 106 108 107 procedure TMainForm. ButtonMatrixIntegerClick(Sender: TObject);109 procedure TMainForm.MatrixIntegerButtonClick(Sender: TObject); 108 110 //var 109 111 // Matrix: TGMatrix<Integer, Integer, Integer>; 110 112 begin 111 113 (* ListViewOutput.Clear; 112 LabelTestName.Caption := 'T MatrixIntegertest';114 LabelTestName.Caption := 'TGMatrix<Integer> test'; 113 115 Matrix := TGMatrix<Integer, Integer, Integer>.Create; 114 116 with Matrix do try … … 133 135 end; 134 136 135 procedure TMainForm. ButtonListObjectClick(Sender: TObject);136 //var137 //List: TListObject<TObject>;138 //I: Integer;139 begin 140 (*ListViewOutput.Clear;141 LabelTestName.Caption := 'T ListObjecttest';142 List := TG ListObject<TObject>.Create;137 procedure TMainForm.ListObjectButtonClick(Sender: TObject); 138 var 139 List: TGObjectList<TObject>; 140 I: Integer; 141 begin 142 ListViewOutput.Clear; 143 LabelTestName.Caption := 'TObjectList<TObject> test'; 144 List := TGObjectList<TObject>.Create; 143 145 with List do try 144 146 AddArray([TObject.Create, TObject.Create, TObject.Create, TObject.Create]); … … 155 157 finally 156 158 Free; 157 end; *)158 end; 159 160 procedure TMainForm. ButtonQueueIntegerClick(Sender: TObject);159 end; 160 end; 161 162 procedure TMainForm.QueueIntegerButtonClick(Sender: TObject); 161 163 var 162 164 Queue: TGQueue<Integer>; 163 165 begin 164 166 ListViewOutput.Clear; 165 LabelTestName.Caption := 'T QueueIntegertest';167 LabelTestName.Caption := 'TGQueue<Integer> test'; 166 168 Queue := TGQueue<Integer>.Create; 167 169 with Queue do try … … 179 181 end; 180 182 181 procedure TMainForm. ButtonStreamByteClick(Sender: TObject);183 procedure TMainForm.StreamByteButtonClick(Sender: TObject); 182 184 var 183 185 Stream: TGStream<Byte>; … … 187 189 begin 188 190 ListViewOutput.Clear; 189 LabelTestName.Caption := 'T StreamBytetest';191 LabelTestName.Caption := 'TGStream<Byte> test'; 190 192 Stream := TGStream<Byte>.Create; 191 193 with Stream do try … … 221 223 end; 222 224 223 procedure TMainForm. ButtonDictionaryStringClick(Sender: TObject);225 procedure TMainForm.DictionaryStringButtonClick(Sender: TObject); 224 226 //type 225 227 // TPairStringString = TGPair<string, string>; … … 228 230 begin 229 231 ListViewOutput.Clear; 230 LabelTestName.Caption := 'T DictionaryStringtest';232 LabelTestName.Caption := 'TGDictionary<string, string> test'; 231 233 Dictionary := TGDictionary<string, string>.Create; 232 234 with Dictionary do try … … 251 253 end; 252 254 253 procedure TMainForm. ButtonCharListClick(Sender: TObject);254 var 255 List: T ListChar;256 List2: T ListChar;257 begin 258 ListViewOutput.Clear; 259 LabelTestName.Caption := 'T ListChartest';260 List := T ListChar.Create;261 List2 := T ListChar.Create;255 procedure TMainForm.CharListButtonClick(Sender: TObject); 256 var 257 List: TGString<Char>; 258 List2: TGString<Char>; 259 begin 260 ListViewOutput.Clear; 261 LabelTestName.Caption := 'TGString<Char> test'; 262 List := TGString<Char>.Create; 263 List2 := TGString<Char>.Create; 262 264 with List do try 263 265 AddArray([' ', ' ', 'A', 'b', 'c', 'd', ' ']); … … 293 295 SampleCount: Integer = 100000; 294 296 begin 295 LabelTestName.Caption := 'Generic specialized T ListStringvs. classic non-generic TStringList benchmark';297 LabelTestName.Caption := 'Generic specialized TGStringList<string> vs. classic non-generic TStringList benchmark'; 296 298 ListViewOutput.Clear; 297 299 try … … 441 443 R: string; 442 444 begin 443 LabelTestName.Caption := 'Generic specialized T DictionaryStringStringvs. classic non-generic TStringList benchmark';445 LabelTestName.Caption := 'Generic specialized TGDictionary<string,string> vs. classic non-generic TStringList benchmark'; 444 446 ListViewOutput.Clear; 445 447 try … … 537 539 SampleCount: Integer = 100000; 538 540 begin 539 LabelTestName.Caption := 'Generic specialized T ListObjectvs. classic non-generic TFPList benchmark';541 LabelTestName.Caption := 'Generic specialized TGObjectList<Object> vs. classic non-generic TFPList benchmark'; 540 542 ListViewOutput.Clear; 541 543 try … … 728 730 end; 729 731 730 procedure TMainForm. ButtonStringListClick(Sender: TObject);732 procedure TMainForm.StringListButtonClick(Sender: TObject); 731 733 var 732 734 List: TGList<String>; 733 735 begin 734 736 ListViewOutput.Clear; 735 WriteOutput('T ListStringtest');737 WriteOutput('TGList<string> test'); 736 738 List := TGList<String>.Create; 737 739 with List do try … … 759 761 end; 760 762 763 procedure TMainForm.TreeButtonClick(Sender: TObject); 764 var 765 Tree: TGTree<string>; 766 //Tree2: TGTree<string>; 767 I: Integer; 768 begin 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;} 803 end; 804 761 805 procedure TMainForm.UpdateButtonState(Enabled: Boolean); 762 806 begin 763 807 ButtonBenchmarkDictionary.Enabled := Enabled; 764 808 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; 772 816 end; 773 817
Note:
See TracChangeset
for help on using the changeset viewer.