Changeset 37 for Generics/UMainForm.pas
- Timestamp:
- Aug 4, 2010, 1:49:55 PM (14 years ago)
- Location:
- Generics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics
- Property svn:ignore
-
old new 1 1 lib 2 2 project1.exe 3 heaptrclog.trc 4 Test.exe
-
- Property svn:ignore
-
Generics/UMainForm.pas
r36 r37 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 GenericList ;9 GenericList, GenericSet; 10 10 11 11 type 12 13 { TMyObject } 14 15 TMyObject = class 16 Name: string; 17 constructor Create(AName: string); 18 end; 19 20 TMyObjectList = specialize TGList<Integer, TMyObject>; 21 12 22 { TMainForm } 13 23 … … 15 25 Memo1: TMemo; 16 26 procedure FormCreate(Sender: TObject); 27 procedure FormDestroy(Sender: TObject); 17 28 procedure FormShow(Sender: TObject); 18 29 private 19 30 { private declarations } 20 31 public 21 IntegerList: TIntegerList; 22 StringList: TStringList; 32 IntegerList: TIntegerGList; 33 StringList: TStringGList; 34 MyObjectList: TMyObjectList; 23 35 end; 24 36 … … 34 46 procedure TMainForm.FormCreate(Sender: TObject); 35 47 begin 36 IntegerList := TIntegerList.Create; 37 StringList := TStringList.Create; 48 IntegerList := TIntegerGList.Create; 49 StringList := TStringGList.Create; 50 MyObjectList := TMyObjectList.Create; 51 end; 52 53 procedure TMainForm.FormDestroy(Sender: TObject); 54 begin 55 IntegerList.Destroy; 56 StringList.Destroy; 57 MyObjectList.Destroy; 38 58 end; 39 59 … … 53 73 IntegerList.Add(12121); 54 74 IntegerList.Add(5); 75 76 for I := 0 to StringList.Count - 1 do 77 Memo1.Lines.Add(StringList[I]); 78 55 79 StringList.Add('One'); 56 80 StringList.Add('Two'); 57 81 StringList.Add('Three'); 58 82 59 for I := 0 to StringList.Count - 1 do60 Memo1.Lines.Add(StringList[I]);61 62 83 IntegerList.Sort(@IntegerListCompare); 63 84 for I := 0 to IntegerList.Count - 1 do 64 85 Memo1.Lines.Add(IntToStr(IntegerList[I])); 86 87 MyObjectList.Add(TMyObject.Create('Object 1')); 88 MyObjectList.Add(TMyObject.Create('Object 2')); 89 MyObjectList.Add(TMyObject.Create('Object 3')); 90 91 for I := 0 to MyObjectList.Count - 1 do 92 Memo1.Lines.Add(MyObjectList[I].Name); 93 end; 94 95 { TObjectItem } 96 97 constructor TMyObject.Create(AName: string); 98 begin 99 Name := AName; 65 100 end; 66 101
Note:
See TracChangeset
for help on using the changeset viewer.