Ignore:
Timestamp:
Aug 14, 2012, 7:04:04 AM (12 years ago)
Author:
chronos
Message:
  • Modified: TemplateGenerics TBinarySerializer now use TListByte class instead TStreamByte.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericList.inc

    r383 r405  
    3939    procedure SetCount(const AValue: TGListIndex); virtual;
    4040  public
     41    type
     42      PItem = ^TGListItem;
    4143    function CompareMem(P1, P2: Pointer; Length: cardinal): Boolean; inline;
    4244    function Add(Item: TGListItem): TGListIndex;
     
    5759    function GetArray(Index, ACount: TGListIndex): TGListItemArray;
    5860    procedure GetList(List: TGList; Index, ACount: TGListIndex);
     61    procedure GetBuffer(Index: TGListIndex; var Buffer; Count: TGListIndex);
    5962    function Implode(Separator: string; Converter: TGListToStringConverter): string;
    6063    function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex; virtual;
     
    7376    procedure ReplaceListPart(Index: TGListIndex; Source: TGList;
    7477      SourceIndex, SourceCount: TGListIndex);
     78    procedure ReplaceBuffer(Index: TGListIndex; var Buffer; Count: TGListIndex);
    7579    procedure Sort(Compare: TGListSortCompare);
    7680    procedure SetArray(Values: array of TGListItem);
     
    102106begin
    103107  FCount := 0;
     108end;
     109
     110procedure TGList.GetBuffer(Index: TGListIndex; var Buffer; Count: TGListIndex);
     111var
     112  P: PItem;
     113  I: TGListIndex;
     114begin
     115  if (Index + Count) > FCount then
     116    raise EListError.CreateFmt(SListIndexError, [Index + Count]);
     117  P := PItem(@Buffer);
     118  I := 0;
     119  while I < Count do begin
     120    P^ := Items[Index + I];
     121    Inc(P, 1);
     122    I := I + 1;
     123  end;
     124end;
     125
     126procedure TGList.ReplaceBuffer(Index: TGListIndex; var Buffer; Count: TGListIndex);
     127var
     128  P: PItem;
     129  I: TGListIndex;
     130begin
     131  if (Index + Count) > FCount then
     132    raise EListError.CreateFmt(SListIndexError, [Index + Count]);
     133  P := PItem(@Buffer);
     134  I := 0;
     135  while I < Count do begin
     136    Items[Index + I] := P^;
     137    Inc(P, 1);
     138    I := I + 1;
     139  end;
    104140end;
    105141
Note: See TracChangeset for help on using the changeset viewer.