Ignore:
Timestamp:
Oct 29, 2010, 7:49:29 AM (14 years ago)
Author:
george
Message:
  • Added: Partial generic set implementation.
  • Modified: TGStack, TGQueue and TGSet owns TGList instead of inherits.
  • Added: TList and TListPointer benchmark comparasion.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/ListImplementation.tpl

    r74 r76  
    11uses
    22  RtlConsts;
    3 
    4 // Used instead of System.Move form because of error: Identifier "System" not found
    5 procedure SystemMove(const Source; var Dest; Count: SizeInt);
    6 begin
    7   Move(Source, Dest, Count);
    8 end;
    93
    104{ TGList }
     
    130124  if FCount = Capacity then Expand;
    131125  if Index < FCount then
    132     SystemMove(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TListItem));
     126    System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TListItem));
    133127  FItems[Index] := Item;
    134128  FCount := FCount + 1;
     
    163157    raise EListError.CreateFmt(SlistIndexError, [NewIndex]);
    164158  Temp := FItems[CurIndex];
    165   Delete(CurIndex);
    166   Insert(NewIndex, Temp);
     159  if NewIndex > CurIndex then begin
     160    System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(TListItem));
     161  end else
     162  if NewIndex < CurIndex then begin
     163    System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(TListItem));
     164  end;
     165  FItems[NewIndex] := Temp;
     166  //Delete(CurIndex);
     167  //Insert(NewIndex, Temp);
    167168end;
    168169
     
    289290    raise EListError.CreateFmt(SListIndexError, [Index]);
    290291  FCount := FCount - 1;
    291   SystemMove(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TListItem));
     292  System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TListItem));
    292293  // Shrink the list if appropriate
    293294  if (Capacity > 256) and (FCount < Capacity shr 2) then
Note: See TracChangeset for help on using the changeset viewer.