- Timestamp:
- Dec 19, 2011, 9:19:00 AM (13 years ago)
- Location:
- Generics/TemplateGenerics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Generic/GenericList.inc
r270 r304 29 29 procedure AddArray(Values: array of TGListItem); 30 30 procedure AddList(List: TGList); 31 procedure AddListPart(List: TGList; ItemIndex, ItemCount: TGListIndex); 31 32 procedure Assign(Source: TGList); virtual; 32 33 constructor Create; virtual; … … 42 43 function GetArray: TGListItemArray; 43 44 function Implode(Separator: string; Converter: TGListToStringConverter): string; 44 function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex; virtual;45 function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex; 45 46 function IndexOfList(List: TGList; Start: TGListIndex = 0): TGListIndex; 46 47 procedure Insert(Index: TGListIndex; Item: TGListItem); … … 51 52 function Remove(Item: TGListItem): TGListIndex; 52 53 procedure Reverse; 53 procedure Replace(Index: TGListIndex; Source: TGList); 54 procedure ReplaceList(Index: TGListIndex; Source: TGList); 55 procedure ReplaceListPart(Index: TGListIndex; Source: TGList; 56 SourceIndex, SourceCount: TGListIndex); 54 57 procedure Sort(Compare: TGListSortCompare); 55 58 procedure SetArray(Values: array of TGListItem); … … 80 83 end; 81 84 82 procedure TGList.Replace (Index: TGListIndex; Source: TGList);85 procedure TGList.ReplaceList(Index: TGListIndex; Source: TGList); 83 86 var 84 87 I: TGListIndex; … … 87 90 while I < Source.Count do begin 88 91 Items[Index + I] := Source[I]; 92 I := I + 1; 93 end; 94 end; 95 96 procedure TGList.ReplaceListPart(Index: TGListIndex; Source: TGList; 97 SourceIndex, SourceCount: TGListIndex); 98 var 99 I: TGListIndex; 100 begin 101 I := 0; 102 while I < SourceCount do begin 103 Items[Index + I] := Source[SourceIndex + I]; 89 104 I := I + 1; 90 105 end; … … 374 389 I := 0; 375 390 while I < Count do begin 376 if not CompareMem( @FItems[I], @List.FItems[I], SizeOf(TGListItem)) then begin391 if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(TGListItem)) then begin 377 392 Result := False; 378 393 Break; … … 469 484 var 470 485 I: TGListIndex; 471 begin 472 I := 0; 473 while I < List.Count do begin 474 Add(List[I]); 475 I := I + 1; 486 J: TGListIndex; 487 begin 488 I := Count; 489 J := 0; 490 Count := Count + List.Count; 491 while I < Count do begin 492 Items[I] := List[J]; 493 I := I + 1; 494 J := J + 1; 495 end; 496 end; 497 498 procedure TGList.AddListPart(List: TGList; ItemIndex, ItemCount: TGListIndex); 499 var 500 I: TGListIndex; 501 J: TGListIndex; 502 begin 503 I := Count; 504 J := ItemIndex; 505 Count := Count + ItemCount; 506 while I < Count do begin 507 Items[I] := List[J]; 508 I := I + 1; 509 J := J + 1; 476 510 end; 477 511 end; -
Generics/TemplateGenerics/Specialized/SpecializedList.pas
r232 r304 90 90 TListByte = class(TListByteBase) 91 91 procedure WriteToStream(Stream: TStream); 92 procedure WriteToStreamPart(Stream: TStream; ItemIndex, ItemCount: TGListIndex); 93 procedure ReplaceStream(Stream: TStream); 94 procedure ReplaceStreamPart(Stream: TStream; ItemIndex, ItemCount: TGListIndex); 95 procedure AddStream(Stream: TStream); 96 procedure AddStreamPart(Stream: TStream; ItemCount: TGListIndex); 92 97 end; 93 98 … … 338 343 end; 339 344 345 { TListByte } 346 340 347 procedure TListByte.WriteToStream(Stream: TStream); 341 348 var 342 349 I: Integer; 343 350 begin 351 Stream.Position := 0; 344 352 I := 0; 345 while I < Count do 353 while I < Count do begin 346 354 Stream.WriteByte(Items[I]); 347 end; 348 355 I := I + 1; 356 end; 357 end; 358 359 procedure TListByte.WriteToStreamPart(Stream: TStream; ItemIndex, ItemCount: Integer); 360 var 361 I: Integer; 362 begin 363 I := ItemIndex; 364 while I < ItemCount do begin 365 Stream.WriteByte(Items[I]); 366 I := I + 1; 367 end; 368 end; 369 370 procedure TListByte.ReplaceStream(Stream: TStream); 371 var 372 I: Integer; 373 begin 374 Stream.Position := 0; 375 I := 0; 376 while I < Count do begin 377 Items[I] := Stream.ReadByte; 378 I := I + 1; 379 end; 380 end; 381 382 procedure TListByte.ReplaceStreamPart(Stream: TStream; ItemIndex, 383 ItemCount: Integer); 384 var 385 I: Integer; 386 begin 387 I := ItemIndex; 388 while I < ItemCount do begin 389 Items[I] := Stream.ReadByte; 390 I := I + 1; 391 end; 392 end; 393 394 procedure TListByte.AddStream(Stream: TStream); 395 var 396 I: Integer; 397 begin 398 Stream.Position := 0; 399 I := Count; 400 Count := Count + Stream.Size; 401 while I < Count do begin 402 Items[I] := Stream.ReadByte; 403 I := I + 1; 404 end; 405 end; 406 407 procedure TListByte.AddStreamPart(Stream: TStream; ItemCount: Integer); 408 var 409 I: Integer; 410 begin 411 I := Count; 412 Count := Count + ItemCount; 413 while I < Count do begin 414 Items[I] := Stream.ReadByte; 415 I := I + 1; 416 end; 417 end; 349 418 350 419 end.
Note:
See TracChangeset
for help on using the changeset viewer.