Ignore:
Timestamp:
Feb 8, 2012, 9:47:54 AM (13 years ago)
Author:
chronos
Message:
  • Added: TGMemoryStream implementation.
  • Added: Additional methods to TGList.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/NativeGenerics/Units/GenericList.pas

    r321 r322  
    3838    procedure AddArray(Values: array of TItem);
    3939    procedure AddList(List: TGList<TItem>);
     40    procedure AddListPart(List: TGList<TItem>; ItemIndex, ItemCount: TIndex);
    4041    procedure Assign(Source: TGList<TItem>); virtual;
    4142    procedure Clear; virtual;
     
    4849    property First: TItem read GetFirst write SetFirst;
    4950    procedure Fill(Start, Count: TIndex; Value: TItem);
    50     function GetArray: TItemArray;
     51    function GetArray(Index, ACount: TIndex): TItemArray;
     52    procedure GetList(List: TGList<TItem>; Index, ACount: TIndex);
    5153    function Implode(Separator: string; Converter: TToStringConverter): string;
    5254    function IndexOf(Item: TItem; Start: TIndex = 0): TIndex;
     
    161163end;
    162164
    163 function TGList<TItem>.GetArray: TItemArray;
     165function TGList<TItem>.GetArray(Index, ACount: TIndex): TItemArray;
    164166var
    165167  I: Integer;
    166168begin
    167   SetLength(Result, Count);
     169  SetLength(Result, ACount);
    168170  I := 0;
    169171  while I < Count do begin
    170     Result[I] := FItems[I];
    171     I := I + 1;
    172   end;
     172    Result[I] := FItems[Index + I];
     173    I := I + 1;
     174  end;
     175end;
     176
     177procedure TGList<TItem>.GetList(List: TGList; Index, ACount: TIndex);
     178begin
     179 List.Clear;
     180 List.AddListPart(Self, Index, ACount);
    173181end;
    174182
     
    506514end;
    507515
     516procedure TGList<TItem>.AddListPart(List: TGList; ItemIndex, ItemCount: TIndex);
     517var
     518  I: TIndex;
     519  J: TIndex;
     520begin
     521  I := Count;
     522  J := ItemIndex;
     523  Count := Count + ItemCount;
     524  while I < Count do begin
     525    Items[I] := List[J];
     526    I := I + 1;
     527    J := J + 1;
     528  end;
     529end;
     530
    508531procedure TGList<TItem>.Clear;
    509532begin
Note: See TracChangeset for help on using the changeset viewer.