Changeset 196
- Timestamp:
- Mar 12, 2011, 6:53:25 PM (14 years ago)
- Location:
- Generics/TemplateGenerics
- Files:
-
- 2 added
- 3 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 -
Generics/TemplateGenerics/TemplateGenerics.lpk
r107 r196 6 6 <Author Value="Chronos"/> 7 7 <CompilerOptions> 8 <Version Value=" 9"/>8 <Version Value="10"/> 9 9 <PathDelim Value="\"/> 10 10 <SearchPaths> … … 19 19 <Description Value="Generic classes implemented as templates."/> 20 20 <Version Minor="3"/> 21 <Files Count="2 0">21 <Files Count="22"> 22 22 <Item1> 23 23 <Filename Value="ReadMe.txt"/> … … 57 57 </Item9> 58 58 <Item10> 59 <Filename Value="Generic\GenericMatrix.inc"/> 60 <UnitName Value="GenericMatrix"/> 61 </Item10> 62 <Item11> 63 <Filename Value="Generic\GenericListString.inc"/> 64 <UnitName Value="GenericListString"/> 65 </Item11> 66 <Item12> 67 <Filename Value="Generic\GenericBitmap.inc"/> 68 </Item12> 69 <Item13> 70 <Filename Value="Generic\GenericPoint.inc"/> 71 <Type Value="Include"/> 72 </Item13> 73 <Item14> 59 74 <Filename Value="Specialized\SpecializedList.pas"/> 60 75 <UnitName Value="SpecializedList"/> 61 </Item1 0>62 <Item1 1>76 </Item14> 77 <Item15> 63 78 <Filename Value="Specialized\SpecializedDictionary.pas"/> 64 79 <UnitName Value="SpecializedDictionary"/> 65 </Item1 1>66 <Item1 2>80 </Item15> 81 <Item16> 67 82 <Filename Value="Specialized\SpecializedStack.pas"/> 68 83 <UnitName Value="SpecializedStack"/> 69 </Item1 2>70 <Item1 3>84 </Item16> 85 <Item17> 71 86 <Filename Value="Specialized\SpecializedTree.pas"/> 72 87 <UnitName Value="SpecializedTree"/> 73 </Item1 3>74 <Item1 4>88 </Item17> 89 <Item18> 75 90 <Filename Value="Specialized\SpecializedQueue.pas"/> 76 91 <UnitName Value="SpecializedQueue"/> 77 </Item1 4>78 <Item1 5>92 </Item18> 93 <Item19> 79 94 <Filename Value="Specialized\SpecializedSet.pas"/> 80 95 <UnitName Value="SpecializedSet"/> 81 </Item15> 82 <Item16> 83 <Filename Value="Generic\GenericListString.inc"/> 84 <UnitName Value="GenericListString"/> 85 </Item16> 86 <Item17> 87 <Filename Value="Generic\GenericMatrix.inc"/> 88 <UnitName Value="GenericMatrix"/> 89 </Item17> 90 <Item18> 91 <Filename Value="Generic\GenericPoint.inc"/> 92 <Type Value="Include"/> 93 </Item18> 94 <Item19> 96 </Item19> 97 <Item20> 95 98 <Filename Value="Specialized\SpecializedPoint.pas"/> 96 99 <UnitName Value="SpecializedPoint"/> 97 </Item 19>98 <Item2 0>100 </Item20> 101 <Item21> 99 102 <Filename Value="Specialized\SpecializedMatrix.pas"/> 100 103 <UnitName Value="SpecializedMatrix"/> 101 </Item20> 104 </Item21> 105 <Item22> 106 <Filename Value="Specialized\SpecializedBitmap.pas"/> 107 <UnitName Value="SpecializedBitmap"/> 108 </Item22> 102 109 </Files> 103 110 <Type Value="RunAndDesignTime"/> 104 <RequiredPkgs Count=" 1">111 <RequiredPkgs Count="2"> 105 112 <Item1> 113 <PackageName Value="LCL"/> 114 </Item1> 115 <Item2> 106 116 <PackageName Value="FCL"/> 107 117 <MinVersion Major="1" Valid="True"/> 108 </Item 1>118 </Item2> 109 119 </RequiredPkgs> 110 120 <UsageOptions> -
Generics/TemplateGenerics/TemplateGenerics.pas
r107 r196 8 8 9 9 uses 10 10 SpecializedList, SpecializedDictionary, SpecializedStack, SpecializedTree, 11 11 SpecializedQueue, SpecializedSet, SpecializedPoint, SpecializedMatrix, 12 LazarusPackageIntf;12 SpecializedBitmap, LazarusPackageIntf; 13 13 14 14 implementation
Note:
See TracChangeset
for help on using the changeset viewer.