Changeset 77 for Generics/TemplateGenerics/Generic/ListImplementation.tpl
- Timestamp:
- Oct 29, 2010, 1:26:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Generic/ListImplementation.tpl
r76 r77 109 109 end; 110 110 111 function TGList.IndexOf(Item: TListItem ): TListIndex;112 begin 113 Result := 0;111 function TGList.IndexOf(Item: TListItem; Start: TListIndex): TListIndex; 112 begin 113 Result := Start; 114 114 while (Result < FCount) and 115 115 not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TListItem)) do … … 138 138 I := I + 1; 139 139 end; 140 end; 141 142 function TGList.IndexOfList(List: TGList; Start: TListIndex): TListIndex; 143 var 144 I: TListIndex; 145 begin 146 if List.Count > 0 then begin 147 Result := IndexOf(List[0], Start); 148 if Result <> -1 then begin 149 I := 1; 150 while I < List.Count do begin 151 if not CompareMem(Addr(FItems[Result + I]), Addr(List.FItems[I]), SizeOf(TListItem)) then begin 152 Result := -1; 153 Break; 154 end; 155 I := I + 1; 156 end; 157 end; 158 end else Result := -1; 140 159 end; 141 160 … … 200 219 end; 201 220 202 (*function TGList.Equals(Obj: TObject): Boolean;203 var 204 I: TListIndex; 205 begin 206 Result := Count = (Obj as TGList).Count;221 function TGList.Equals(List: TGList): Boolean; 222 var 223 I: TListIndex; 224 begin 225 Result := Count = List.Count; 207 226 if Result then begin 208 227 I := 0; 209 228 while I < Count do begin 210 if Items[I] <> (Obj as TGList)[I]then begin229 if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(TListItem)) then begin 211 230 Result := False; 212 231 Break; … … 215 234 end; 216 235 end; 217 end; *)236 end; 218 237 219 238 procedure TGList.Reverse; … … 241 260 while I <= High(Values) do begin 242 261 Add(Values[I]); 262 I := I + 1; 263 end; 264 end; 265 266 procedure TGList.SetArray(Values: array of TListItem); 267 var 268 I: TListIndex; 269 begin 270 Clear; 271 I := 0; 272 while I <= High(Values) do begin 273 Add(Values[I]); 274 I := I + 1; 275 end; 276 end; 277 278 procedure TGList.InsertArray(Index: TListIndex; Values: array of TListItem); 279 var 280 I: TListIndex; 281 begin 282 I := 0; 283 while I <= High(Values) do begin 284 Insert(Index + I, Values[I]); 243 285 I := I + 1; 244 286 end; … … 255 297 if I < (Count - 1) then 256 298 Result := Result + Separator; 299 I := I + 1; 300 end; 301 end; 302 303 procedure TGList.Perform(Operation: TGListOperation); 304 var 305 I: TListIndex; 306 begin 307 I := 0; 308 while I < Count do begin 309 Operation(Self, @FItems[I]); 257 310 I := I + 1; 258 311 end; … … 309 362 end; 310 363 364 procedure TGList.Fill(Start, Count: TListIndex; Value: TListItem); 365 begin 366 while Count > 0 do begin 367 Items[Start] := Value; 368 Count := Count - 1; 369 Start := Start + 1; 370 end; 371 end; 372 311 373 procedure TGList.Exchange(Index1, Index2: TListIndex); 312 374 var
Note:
See TracChangeset
for help on using the changeset viewer.