Changeset 379 for Generics/NativeGenerics/Units/GenericMatrix.pas
- Timestamp:
- Jun 21, 2012, 10:39:13 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/NativeGenerics/Units/GenericMatrix.pas
r324 r379 19 19 TRow = array of TItem; 20 20 TMerge = function(Item1, Item2: TItem): TItem of object; 21 PItem = ^TItem; 21 22 22 23 TIndex = record … … 68 69 function Add(Item: TItem): TIndex; 69 70 procedure AddMatrix(Values: array of TRow); 70 procedure AddList(List: TGMatrix );71 procedure Assign(Source: TGMatrix );71 procedure AddList(List: TGMatrix<TItem>); 72 procedure Assign(Source: TGMatrix<TItem>); 72 73 procedure Clear; virtual; 73 74 procedure Contract; … … 75 76 procedure Delete(Index: TIndex); virtual; 76 77 procedure DeleteItems(Index, Count: TIndex); 77 function EqualTo(List: TGMatrix ): Boolean;78 function EqualTo(List: TGMatrix<TItem>): Boolean; 78 79 procedure Expand; 79 80 function Extract(Item: TItem): TItem; … … 85 86 procedure Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1); 86 87 function IndexOf(Item: TItem; Start: TIndex = 0): TIndex; 87 function IndexOfList(List: TGMatrix ; Start: TIndex = 0): TIndex;88 function IndexOfList(List: TGMatrix<TItem>; Start: TIndex = 0): TIndex; 88 89 procedure Insert(Index: TIndex; Item: TItem); 89 procedure InsertList(Index: TIndex; List: TGMatrix );90 procedure InsertList(Index: TIndex; List: TGMatrix<TItem>); 90 91 procedure InsertArray(Index: TIndex; Values: array of TItem); 91 92 procedure Move(CurIndex, NewIndex: TIndex); 92 93 procedure MoveItems(CurIndex, NewIndex, Count: TIndex); 93 procedure Merge(Index: TIndex; Source: TGMatrix ; Proc: TMerge);94 procedure Replace(Index: TIndex; Source: TGMatrix );94 procedure Merge(Index: TIndex; Source: TGMatrix<TItem>; Proc: TMerge); 95 procedure Replace(Index: TIndex; Source: TGMatrix<TItem>); 95 96 function Remove(Item: TItem): TIndex; 96 97 procedure Reverse; … … 107 108 TIndex = TGAbstractMatrix<TItem>.TIndex; 108 109 private 110 FRowSize: Integer; 111 FCellSize: Integer; 109 112 FData: Pointer; 110 113 FCount: TIndex; 114 public 115 constructor Create; 116 function GetItemXY(X: TIndexX; Y: TIndexY): TItem; override; 117 procedure PutItemXY(X: TIndexX; Y: TIndexY; const AValue: TItem); override; 118 property Data: Pointer read FData; 119 property Count: TIndex read FCount write SetCount; 111 120 end; 112 121 … … 120 129 121 130 131 { TGRawMatrix } 132 133 constructor TGRawMatrix<TItem>.Create; 134 begin 135 FCellSize := SizeOf(TItem); 136 end; 137 138 function TGRawMatrix<TItem>.GetItemXY(X: TIndexX; Y: TIndexY): TItem; 139 begin 140 Result := PItem(X * FCellSize + Y * FRowSize)^; 141 end; 142 143 procedure TGRawMatrix<TItem>.PutItemXY(X: TIndexX; Y: TIndexY; const AValue: TItem); 144 begin 145 PItem(X * FCellSize + Y * FRowSize)^ := AValue; 146 end; 147 122 148 { TGMatrix } 123 149 124 procedure TGMatrix<TItem>.Replace(Index: TIndex; Source: TGMatrix );150 procedure TGMatrix<TItem>.Replace(Index: TIndex; Source: TGMatrix<TItem>); 125 151 var 126 152 X: TIndexX; … … 138 164 end; 139 165 140 procedure TGMatrix<TItem>.Merge(Index: TIndex; Source: TGMatrix ; Proc: TMerge);166 procedure TGMatrix<TItem>.Merge(Index: TIndex; Source: TGMatrix<TItem>; Proc: TMerge); 141 167 var 142 168 X: TIndexX; … … 221 247 end; 222 248 223 procedure TGMatrix<TItem>.Assign(Source: TGMatrix );249 procedure TGMatrix<TItem>.Assign(Source: TGMatrix<TItem>); 224 250 var 225 251 Index: TIndex; … … 309 335 end; 310 336 311 procedure TGMatrix<TItem>.InsertList(Index: TIndex; List: TGMatrix );337 procedure TGMatrix<TItem>.InsertList(Index: TIndex; List: TGMatrix<TItem>); 312 338 var 313 339 I: TIndex; … … 321 347 end; 322 348 323 function TGMatrix<TItem>.IndexOfList(List: TGMatrix ; Start: TIndex): TIndex;349 function TGMatrix<TItem>.IndexOfList(List: TGMatrix<TItem>; Start: TIndex): TIndex; 324 350 var 325 351 I: TIndex; … … 429 455 end; 430 456 431 function TGMatrix<TItem>.EqualTo(List: TGMatrix ): Boolean;457 function TGMatrix<TItem>.EqualTo(List: TGMatrix<TItem>): Boolean; 432 458 var 433 459 I: TIndex; … … 575 601 end; 576 602 577 procedure TGMatrix<TItem>.AddList(List: TGMatrix );603 procedure TGMatrix<TItem>.AddList(List: TGMatrix<TItem>); 578 604 var 579 605 I: TIndex;
Note:
See TracChangeset
for help on using the changeset viewer.