Changeset 196 for Generics


Ignore:
Timestamp:
Mar 12, 2011, 6:53:25 PM (13 years ago)
Author:
george
Message:
  • Added: Generic Bitmap class.
  • Modified: Swaped X, Y parameters in ItemsXY property of generic TMatrix.
Location:
Generics/TemplateGenerics
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericMatrix.inc

    r175 r196  
    1919    FItems: array of array of TGMatrixItem;
    2020    FCount: TGMatrixIndex;
    21     function GetXY(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;
    2323    function GetCapacity: TGMatrixIndex;
    2424    function GetLast: TGMatrixItem;
     
    2727    procedure SetLast(AValue: TGMatrixItem);
    2828    procedure SetFirst(AValue: TGMatrixItem);
    29     procedure PutXY(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;
    3131    procedure SetCount(const AValue: TGMatrixIndex);
    3232  public
     
    4545    procedure Exchange(Index1, Index2: TGMatrixIndex);
    4646    property First: TGMatrixItem read GetFirst write SetFirst;
     47    procedure FillAll(Value: TGMatrixItem);
    4748    procedure Fill(Start, Count: TGMatrixIndex; Value: TGMatrixItem);
    4849    function Implode(RowSeparator, ColSeparator: string; Converter: TGMatrixToStringConverter): string;
     
    6566    property Count: TGMatrixIndex read FCount write SetCount;
    6667    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;
    6972    property Last: TGMatrixItem read GetLast write SetLast;
    7073  end;
     
    97100    X := 0;
    98101    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];
    100103      X := X + 1;
    101104    end;
     
    113116    X := 0;
    114117    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]);
    116119      X := X + 1;
    117120    end;
     
    149152end;
    150153
    151 function TGMatrix.GetXY(Y: TGMatrixIndexY; X: TGMatrixIndexX): TGMatrixItem;
     154function TGMatrix.GetItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY): TGMatrixItem;
    152155begin
    153156  if (X < 0) or (X >= Count.X) or
     
    157160end;
    158161
    159 function TGMatrix.Get(Index: TGMatrixIndex): TGMatrixItem;
     162function TGMatrix.GetItem(Index: TGMatrixIndex): TGMatrixItem;
    160163begin
    161164  if (Index.X < 0) or (Index.X >= Count.X) or
     
    165168end;
    166169
    167 procedure TGMatrix.PutXY(Y: TGMatrixIndexY; X: TGMatrixIndexX; const AValue: TGMatrixItem);
     170procedure TGMatrix.PutItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY; const AValue: TGMatrixItem);
    168171begin
    169172  if (X < 0) or (X >= Count.X) or
     
    173176end;
    174177
    175 procedure TGMatrix.Put(Index: TGMatrixIndex; const AValue: TGMatrixItem);
     178procedure TGMatrix.PutItem(Index: TGMatrixIndex; const AValue: TGMatrixItem);
    176179begin
    177180  if (Index.X < 0) or (Index.X >= Count.X) or
     
    510513    X := 0;
    511514    while X < Count.X do begin
    512       Result := Result + Converter(ItemsXY[Y, X]);
     515      Result := Result + Converter(ItemsXY[X, Y]);
    513516      if X < (Count.X - 1) then
    514517        Result := Result + ColSeparator;
     
    589592    X := Start.X;
    590593    while X < Count.X do begin
    591       ItemsXY[Y, X] := Value;
     594      ItemsXY[X, Y] := Value;
    592595      X := X + 1;
    593596    end;
    594597    Y := Y + 1;
    595598  end;
     599end;
     600
     601procedure TGMatrix.FillAll(Value: TGMatrixItem);
     602begin
     603  Fill(CreateIndex(0, 0), CreateIndex(Count.X - 1, Count.Y - 1), Value);
    596604end;
    597605
  • Generics/TemplateGenerics/TemplateGenerics.lpk

    r107 r196  
    66    <Author Value="Chronos"/>
    77    <CompilerOptions>
    8       <Version Value="9"/>
     8      <Version Value="10"/>
    99      <PathDelim Value="\"/>
    1010      <SearchPaths>
     
    1919    <Description Value="Generic classes implemented as templates."/>
    2020    <Version Minor="3"/>
    21     <Files Count="20">
     21    <Files Count="22">
    2222      <Item1>
    2323        <Filename Value="ReadMe.txt"/>
     
    5757      </Item9>
    5858      <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>
    5974        <Filename Value="Specialized\SpecializedList.pas"/>
    6075        <UnitName Value="SpecializedList"/>
    61       </Item10>
    62       <Item11>
     76      </Item14>
     77      <Item15>
    6378        <Filename Value="Specialized\SpecializedDictionary.pas"/>
    6479        <UnitName Value="SpecializedDictionary"/>
    65       </Item11>
    66       <Item12>
     80      </Item15>
     81      <Item16>
    6782        <Filename Value="Specialized\SpecializedStack.pas"/>
    6883        <UnitName Value="SpecializedStack"/>
    69       </Item12>
    70       <Item13>
     84      </Item16>
     85      <Item17>
    7186        <Filename Value="Specialized\SpecializedTree.pas"/>
    7287        <UnitName Value="SpecializedTree"/>
    73       </Item13>
    74       <Item14>
     88      </Item17>
     89      <Item18>
    7590        <Filename Value="Specialized\SpecializedQueue.pas"/>
    7691        <UnitName Value="SpecializedQueue"/>
    77       </Item14>
    78       <Item15>
     92      </Item18>
     93      <Item19>
    7994        <Filename Value="Specialized\SpecializedSet.pas"/>
    8095        <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>
    9598        <Filename Value="Specialized\SpecializedPoint.pas"/>
    9699        <UnitName Value="SpecializedPoint"/>
    97       </Item19>
    98       <Item20>
     100      </Item20>
     101      <Item21>
    99102        <Filename Value="Specialized\SpecializedMatrix.pas"/>
    100103        <UnitName Value="SpecializedMatrix"/>
    101       </Item20>
     104      </Item21>
     105      <Item22>
     106        <Filename Value="Specialized\SpecializedBitmap.pas"/>
     107        <UnitName Value="SpecializedBitmap"/>
     108      </Item22>
    102109    </Files>
    103110    <Type Value="RunAndDesignTime"/>
    104     <RequiredPkgs Count="1">
     111    <RequiredPkgs Count="2">
    105112      <Item1>
     113        <PackageName Value="LCL"/>
     114      </Item1>
     115      <Item2>
    106116        <PackageName Value="FCL"/>
    107117        <MinVersion Major="1" Valid="True"/>
    108       </Item1>
     118      </Item2>
    109119    </RequiredPkgs>
    110120    <UsageOptions>
  • Generics/TemplateGenerics/TemplateGenerics.pas

    r107 r196  
    88
    99uses
    10     SpecializedList, SpecializedDictionary, SpecializedStack, SpecializedTree,
     10  SpecializedList, SpecializedDictionary, SpecializedStack, SpecializedTree,
    1111  SpecializedQueue, SpecializedSet, SpecializedPoint, SpecializedMatrix,
    12   LazarusPackageIntf;
     12  SpecializedBitmap, LazarusPackageIntf;
    1313
    1414implementation
Note: See TracChangeset for help on using the changeset viewer.