Ignore:
Timestamp:
Feb 8, 2012, 1:04:21 PM (13 years ago)
Author:
chronos
Message:
  • Modified: TListChar in unit SpecializedList replaced by more general TGString in GenericString.
  • Added: TGBitmap example implementation.
  • Modified: TGList splitted to TGAbstractList and TGList as memory implementation.
  • Modified: TGMatrix splitted to TGAbstractMatrix and TGMatrix as memory implementation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/NativeGenerics/Units/GenericMatrix.pas

    r321 r324  
    99
    1010type
    11   TGMatrix<TItem> = class
     11  TGAbstractMatrix<TItem> = class
    1212  public
    1313    type
     
    2424        Y: TIndexY;
    2525      end;
     26  protected
     27    function GetItemXY(X: TIndexX; Y: TIndexY): TItem; virtual; abstract;
     28    procedure PutItemXY(X: TIndexX; Y: TIndexY; const AValue: TItem); virtual; abstract;
     29    function GetItem(Index: TIndex): TItem; virtual; abstract;
     30    function GetCapacity: TIndex; virtual; abstract;
     31    function GetLast: TItem; virtual; abstract;
     32    function GetFirst: TItem; virtual; abstract;
     33    function GetCount: TIndex; virtual; abstract;
     34    procedure SetLast(AValue: TItem); virtual; abstract;
     35    procedure SetFirst(AValue: TItem); virtual; abstract;
     36    procedure PutItem(Index: TIndex; const AValue: TItem);  virtual; abstract;
     37    procedure SetCount(const AValue: TIndex); virtual; abstract;
     38  public
     39    property Count: TIndex read GetCount write SetCount;
     40    property ItemsXY[X: TIndexX; Y: TIndexY]: TItem
     41      read GetItemXY write PutItemXY; default;
     42    property Items[Index: TIndex]: TItem
     43      read GetItem write PutItem;
     44    property Last: TItem read GetLast write SetLast;
     45  end;
     46
     47  TGMatrix<TItem> = class(TGAbstractMatrix<TItem>)
     48  public
     49    type
     50      TIndex = TGAbstractMatrix<TItem>.TIndex;
     51  protected
     52    function GetItemXY(X: TIndexX; Y: TIndexY): TItem; override;
     53    procedure PutItemXY(X: TIndexX; Y: TIndexY; const AValue: TItem); override;
     54    function GetItem(Index: TIndex): TItem; override;
     55    function GetLast: TItem; override;
     56    function GetFirst: TItem; override;
     57    function GetCount: TIndex; override;
     58    procedure SetLast(AValue: TItem); override;
     59    procedure SetFirst(AValue: TItem); override;
     60    procedure PutItem(Index: TIndex; const AValue: TItem);  override;
     61    procedure SetCount(const AValue: TIndex); override;
    2662  private
    2763    FItems: array of array of TItem;
    2864    FCount: TIndex;
    29     function GetItemXY(X: TIndexX; Y: TIndexY): TItem;
    30     function GetItem(Index: TIndex): TItem;
    31     function GetCapacity: TIndex;
    32     function GetLast: TItem;
    33     function GetFirst: TItem;
     65    function GetCapacity: TIndex; override;
    3466    procedure SetCapacity(const AValue: TIndex);
    35     procedure SetLast(AValue: TItem);
    36     procedure SetFirst(AValue: TItem);
    37     procedure PutItemXY(X: TIndexX; Y: TIndexY; const AValue: TItem); virtual;
    38     procedure PutItem(Index: TIndex; const AValue: TItem); virtual;
    39     procedure SetCount(const AValue: TIndex);
    4067  public
    4168    function Add(Item: TItem): TIndex;
     
    7299    procedure Sort(Compare: TSortCompare);
    73100    procedure SetArray(Values: array of TItem);
    74     property Count: TIndex read FCount write SetCount;
    75101    property Capacity: TIndex read GetCapacity write SetCapacity;
    76     property ItemsXY[X: TIndexX; Y: TIndexY]: TItem
    77       read GetItemXY write PutItemXY; default;
    78     property Items[Index: TIndex]: TItem
    79       read GetItem write PutItem;
    80     property Last: TItem read GetLast write SetLast;
     102  end;
     103
     104  TGRawMatrix<TItem> = class(TGAbstractMatrix<TItem>)
     105  public
     106    type
     107      TIndex = TGAbstractMatrix<TItem>.TIndex;
     108  private
     109    FData: Pointer;
     110    FCount: TIndex;
    81111  end;
    82112
     
    620650end;
    621651
     652function TGMatrix<TItem>.GetCount: TIndex;
     653begin
     654  Result := FCount;
     655end;
     656
     657
    622658end.
Note: See TracChangeset for help on using the changeset viewer.