Changeset 219 for Generics/TemplateGenerics/Generic
- Timestamp:
- Mar 24, 2011, 6:50:50 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Generic/GenericList.inc
r175 r219 25 25 procedure QuickSort(L, R : TGListIndex; Compare: TGListSortCompare); 26 26 public 27 function CompareMem(P1, P2: Pointer; Length: cardinal): Boolean; inline; 27 28 function Add(Item: TGListItem): TGListIndex; 28 29 procedure AddArray(Values: array of TGListItem); … … 208 209 end; 209 210 211 function TGList.CompareMem(P1, P2: Pointer; Length: cardinal): Boolean; 212 var 213 I: Cardinal; 214 begin 215 Result := True; 216 I := 0; 217 if (P1) <> (P2) then 218 while Result and (I < Length) do 219 begin 220 Result := PByte(P1)^ = PByte(P2)^; 221 Inc(I); 222 Inc(pchar(P1)); 223 Inc(pchar(P2)); 224 end; 225 end; 226 210 227 function TGList.IndexOf(Item: TGListItem; Start: TGListIndex): TGListIndex; 211 228 begin 212 229 Result := Start; 213 230 while (Result < FCount) and 214 not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TGListItem)) do 231 not CompareMem(@FItems[Result], @Item, SizeOf(TGListItem)) do 232 // not (CompareByte(FItems[Result], Item, SizeOf(TGListItem)) = 0) do 215 233 Result := Result + 1; 216 234 if Result = FCount then Result := -1;
Note:
See TracChangeset
for help on using the changeset viewer.