Changeset 109 for Generics/TemplateGenerics/Generic
- Timestamp:
- Jan 3, 2011, 7:22:47 AM (14 years ago)
- Location:
- Generics/TemplateGenerics/Generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Generic/GenericList.inc
r107 r109 181 181 begin 182 182 Result := Start; 183 // Use slower CompareMem instead of (FItems[Result] <> Item) to support records 183 184 while (Result < FCount) and 184 185 not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TGListItem)) do -
Generics/TemplateGenerics/Generic/GenericMatrix.inc
r107 r109 6 6 TGMatrixToStringConverter = function(Item: TGMatrixItem): string; 7 7 TGMatrixFromStringConverter = function(Text: string): TGMatrixItem; 8 TGMatrixRow = array of TGMatrixItem; 8 9 9 10 TGMatrixIndex = record … … 28 29 public 29 30 function Add(Item: TGMatrixItem): TGMatrixIndex; 30 procedure Add Array(Values: array of TGMatrixItem);31 procedure AddMatrix(Values: array of TGMatrixRow); 31 32 procedure AddList(List: TGMatrix); 32 33 procedure Assign(Source: TGMatrix); … … 42 43 property First: TGMatrixItem read GetFirst write SetFirst; 43 44 procedure Fill(Start, Count: TGMatrixIndex; Value: TGMatrixItem); 44 function Implode( Separator: string; Converter: TGMatrixToStringConverter): string;45 function Implode(RowSeparator, ColSeparator: string; Converter: TGMatrixToStringConverter): string; 45 46 procedure Explode(Text, Separator: string; Converter: TGMatrixFromStringConverter; SlicesCount: Integer = -1); 46 47 function IndexOf(Item: TGMatrixItem; Start: TGMatrixIndex = 0): TGMatrixIndex; … … 363 364 end; 364 365 365 procedure TGMatrix.Add Array(Values: array of TGMatrixItem);366 procedure TGMatrix.AddMatrix(Values: array of TGMatrixRow); 366 367 var 367 368 I: TGMatrixIndex; … … 397 398 end; 398 399 399 function TGMatrix.Implode(Separator: string; Converter: TGMatrixToStringConverter): string; 400 var 401 I: TGMatrixIndex; 402 begin 403 (* Result := ''; 404 I := 0; 405 while I < Count do begin 406 Result := Result + Converter(Items[I]); 407 if I < (Count - 1) then 408 Result := Result + Separator; 409 I := I + 1; 410 end; *) 400 function TGMatrix.Implode(RowSeparator, ColSeparator: string; Converter: TGMatrixToStringConverter): string; 401 var 402 Y: TGMatrixIndexY; 403 X: TGMatrixIndexX; 404 begin 405 Result := ''; 406 Y := 0; 407 while Y < Count.Y do begin 408 X := 0; 409 while X < Count.X do begin 410 Result := Result + Converter(Items[Y, X]); 411 if X < (Count.X - 1) then 412 Result := Result + ColSeparator; 413 X := X + 1; 414 end; 415 if Y < (Count.Y - 1) then 416 Result := Result + RowSeparator; 417 Y := Y + 1; 418 end; 411 419 end; 412 420
Note:
See TracChangeset
for help on using the changeset viewer.