Changeset 196 for Generics/TemplateGenerics/Generic
- Timestamp:
- Mar 12, 2011, 6:53:25 PM (14 years ago)
- Location:
- Generics/TemplateGenerics/Generic
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Generic/GenericMatrix.inc
r175 r196 19 19 FItems: array of array of TGMatrixItem; 20 20 FCount: TGMatrixIndex; 21 function Get XY(Y: TGMatrixIndexY; X: TGMatrixIndexX): TGMatrixItem;22 function Get (Index: TGMatrixIndex): TGMatrixItem;21 function GetItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY): TGMatrixItem; 22 function GetItem(Index: TGMatrixIndex): TGMatrixItem; 23 23 function GetCapacity: TGMatrixIndex; 24 24 function GetLast: TGMatrixItem; … … 27 27 procedure SetLast(AValue: TGMatrixItem); 28 28 procedure SetFirst(AValue: TGMatrixItem); 29 procedure Put XY(Y: TGMatrixIndexY; X: TGMatrixIndexX; const AValue: TGMatrixItem); virtual;30 procedure Put (Index: TGMatrixIndex; const AValue: TGMatrixItem); virtual;29 procedure PutItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY; const AValue: TGMatrixItem); virtual; 30 procedure PutItem(Index: TGMatrixIndex; const AValue: TGMatrixItem); virtual; 31 31 procedure SetCount(const AValue: TGMatrixIndex); 32 32 public … … 45 45 procedure Exchange(Index1, Index2: TGMatrixIndex); 46 46 property First: TGMatrixItem read GetFirst write SetFirst; 47 procedure FillAll(Value: TGMatrixItem); 47 48 procedure Fill(Start, Count: TGMatrixIndex; Value: TGMatrixItem); 48 49 function Implode(RowSeparator, ColSeparator: string; Converter: TGMatrixToStringConverter): string; … … 65 66 property Count: TGMatrixIndex read FCount write SetCount; 66 67 property Capacity: TGMatrixIndex read GetCapacity write SetCapacity; 67 property ItemsXY[Y: TGMatrixIndexY; X: TGMatrixIndexX]: TGMatrixItem read GetXY write PutXY; default; 68 property Items[Index: TGMatrixIndex]: TGMatrixItem read Get write Put; 68 property ItemsXY[X: TGMatrixIndexX; Y: TGMatrixIndexY]: TGMatrixItem 69 read GetItemXY write PutItemXY; default; 70 property Items[Index: TGMatrixIndex]: TGMatrixItem 71 read GetItem write PutItem; 69 72 property Last: TGMatrixItem read GetLast write SetLast; 70 73 end; … … 97 100 X := 0; 98 101 while X < Source.Count.X do begin 99 ItemsXY[Index. Y + Y, Index.X + X] := Source.ItemsXY[Y, X];102 ItemsXY[Index.X + X, Index.Y + Y] := Source.ItemsXY[X, Y]; 100 103 X := X + 1; 101 104 end; … … 113 116 X := 0; 114 117 while X < Source.Count.X do begin 115 ItemsXY[Index. Y + Y, Index.X + X] := Proc(ItemsXY[Index.Y + Y, Index.X + X], Source.ItemsXY[Y, X]);118 ItemsXY[Index.X + X, Index.Y + Y] := Proc(ItemsXY[Index.X + X, Index.Y + Y], Source.ItemsXY[X, Y]); 116 119 X := X + 1; 117 120 end; … … 149 152 end; 150 153 151 function TGMatrix.Get XY(Y: TGMatrixIndexY; X: TGMatrixIndexX): TGMatrixItem;154 function TGMatrix.GetItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY): TGMatrixItem; 152 155 begin 153 156 if (X < 0) or (X >= Count.X) or … … 157 160 end; 158 161 159 function TGMatrix.Get (Index: TGMatrixIndex): TGMatrixItem;162 function TGMatrix.GetItem(Index: TGMatrixIndex): TGMatrixItem; 160 163 begin 161 164 if (Index.X < 0) or (Index.X >= Count.X) or … … 165 168 end; 166 169 167 procedure TGMatrix.Put XY(Y: TGMatrixIndexY; X: TGMatrixIndexX; const AValue: TGMatrixItem);170 procedure TGMatrix.PutItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY; const AValue: TGMatrixItem); 168 171 begin 169 172 if (X < 0) or (X >= Count.X) or … … 173 176 end; 174 177 175 procedure TGMatrix.Put (Index: TGMatrixIndex; const AValue: TGMatrixItem);178 procedure TGMatrix.PutItem(Index: TGMatrixIndex; const AValue: TGMatrixItem); 176 179 begin 177 180 if (Index.X < 0) or (Index.X >= Count.X) or … … 510 513 X := 0; 511 514 while X < Count.X do begin 512 Result := Result + Converter(ItemsXY[ Y, X]);515 Result := Result + Converter(ItemsXY[X, Y]); 513 516 if X < (Count.X - 1) then 514 517 Result := Result + ColSeparator; … … 589 592 X := Start.X; 590 593 while X < Count.X do begin 591 ItemsXY[ Y, X] := Value;594 ItemsXY[X, Y] := Value; 592 595 X := X + 1; 593 596 end; 594 597 Y := Y + 1; 595 598 end; 599 end; 600 601 procedure TGMatrix.FillAll(Value: TGMatrixItem); 602 begin 603 Fill(CreateIndex(0, 0), CreateIndex(Count.X - 1, Count.Y - 1), Value); 596 604 end; 597 605
Note:
See TracChangeset
for help on using the changeset viewer.