- Timestamp:
- Sep 8, 2012, 9:28:39 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 backup 4 4 tunneler.exe 5 heaptrclog.trc
-
- Property svn:ignore
-
trunk/Components/TemplateGenerics
-
Property svn:ignore
set to
lib
-
Property svn:ignore
set to
-
trunk/Components/TemplateGenerics/Generic/GenericListObject.inc
r29 r30 13 13 // TGListObject<TListObjectIndex, TListObjectItem> = class(TGList) 14 14 TGListObject = class(TGList) 15 pr ivate15 protected 16 16 procedure Put(Index: TGListIndex; const AValue: TGListItem); override; 17 procedure SetCount(const AValue: TGListIndex); override; 17 18 public 18 19 OwnsObjects: Boolean; 20 function AddNew(NewObject: TGListItem = nil): TGListItem; 21 function InsertNew(Index: TGListIndex; NewObject: TGListItem = nil): TGListItem; 19 22 procedure Delete(Index: TGListObjectIndex); override; 20 procedure Clear; override;21 23 procedure Assign(Source: TGList); override; 22 constructor Create; 24 constructor Create; override; 23 25 destructor Destroy; override; 24 26 end; … … 49 51 { TGListObject } 50 52 53 function TGListObject.AddNew(NewObject: TGListItem = nil): TGListItem; 54 begin 55 if Assigned(NewObject) then Result := NewObject 56 else Result := TGListItem.Create; 57 Add(Result); 58 end; 59 60 function TGListObject.InsertNew(Index: TGListIndex; 61 NewObject: TGListItem = nil): TGListItem; 62 begin 63 if Assigned(NewObject) then Result := NewObject 64 else Result := TGListItem.Create; 65 Insert(Index, Result); 66 end; 67 51 68 procedure TGListObject.Assign(Source: TGList); 52 69 begin … … 58 75 procedure TGListObject.Put(Index: TGListIndex; const AValue: TGListItem); 59 76 begin 60 if OwnsObjects then FItems[Index].Free;77 if OwnsObjects and (FItems[Index] <> AValue) then FItems[Index].Free; 61 78 inherited Put(Index, AValue); 62 79 end; … … 68 85 end; 69 86 70 procedure TGListObject. Clear;87 procedure TGListObject.SetCount(const AValue: TGListIndex); 71 88 var 72 89 I: TGListObjectIndex; 73 90 begin 74 91 if OwnsObjects then begin 75 I := 0;76 while I < Countdo begin92 I := FCount - 1; 93 while I >= AValue do begin 77 94 FItems[I].Free; 78 I := I +1;95 I := I - 1; 79 96 end; 80 97 end; 81 inherited Clear;98 inherited; 82 99 end; 83 100
Note:
See TracChangeset
for help on using the changeset viewer.