Changeset 78 for Generics/TemplateGenerics/Specialized
- Timestamp:
- Oct 30, 2010, 6:39:12 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Specialized/ListObject.pas
r71 r78 15 15 type 16 16 17 { T ObjectList }17 { TListObject } 18 18 19 TObjectList = class(TGList) 20 //OwnObjects: Boolean; 19 TListObject = class(TGList) 20 private 21 procedure Put(Index: TListIndex; const AValue: TListItem); override; 22 public 23 OwnObjects: Boolean; 24 procedure Delete(Index: TListIndex); override; 25 procedure Clear; override; 26 constructor Create; 21 27 destructor Destroy; override; 22 28 end; … … 29 35 { TObjectList } 30 36 31 destructor TObjectList.Destroy;37 procedure TListObject.Put(Index: TListIndex; const AValue: TListItem); 32 38 begin 39 if OwnObjects then FItems[Index].Free; 40 inherited Put(Index, AValue); 41 end; 42 43 procedure TListObject.Delete(Index: TListIndex); 44 begin 45 if OwnObjects then FItems[Index].Free; 46 inherited Delete(Index); 47 end; 48 49 procedure TListObject.Clear; 50 var 51 I: TListIndex; 52 begin 53 if OwnObjects then begin 54 I := 0; 55 while I < Count do begin 56 FItems[I].Free; 57 I := I + 1; 58 end; 59 end; 60 inherited Clear; 61 end; 62 63 constructor TListObject.Create; 64 begin 65 inherited; 66 OwnObjects := True; 67 end; 68 69 destructor TListObject.Destroy; 70 begin 71 Clear; 33 72 inherited Destroy; 34 73 end;
Note:
See TracChangeset
for help on using the changeset viewer.