Changeset 324


Ignore:
Timestamp:
Jun 25, 2024, 11:04:00 AM (5 months ago)
Author:
chronos
Message:
Location:
trunk/Packages/TemplateGenerics
Files:
1 deleted
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Packages/TemplateGenerics/Additional/BinarySerializer.pas

    r323 r324  
    1 unit UBinarySerializer;
    2 
    3 {$mode delphi}{$H+}
     1unit BinarySerializer;
    42
    53interface
     
    217215destructor TBinarySerializer.Destroy;
    218216begin
    219   if OwnsList then FList.Free;
    220   inherited Destroy;
     217  if OwnsList then FreeAndNil(FList);
     218  inherited;
    221219end;
    222220
  • trunk/Packages/TemplateGenerics/Generic/GenericMatrix.inc

    r109 r324  
    2323    function GetItem(Index: TIndex): TGMatrixItem;
    2424    function GetCapacity: TIndex;
    25     function GetLast: TGMatrixItem;
    26     function GetFirst: TGMatrixItem;
    2725    procedure SetCapacity(const AValue: TIndex);
    28     procedure SetLast(AValue: TGMatrixItem);
    29     procedure SetFirst(AValue: TGMatrixItem);
    3026    procedure PutItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY; const AValue: TGMatrixItem); virtual;
    3127    procedure PutItem(Index: TIndex; const AValue: TGMatrixItem); virtual;
    3228    procedure SetCount(const AValue: TIndex);
    3329  public
    34     function Add(Item: TGMatrixItem): TIndex;
    35     procedure AddMatrix(Values: array of TRow);
    36     procedure AddList(List: TGMatrix);
    3730    procedure Assign(Source: TGMatrix);
    3831    procedure Clear; virtual;
    3932    procedure Contract;
    4033    function CreateIndex(X: TGMatrixIndexY; Y: TGMatrixIndexX): TIndex;
    41     procedure Delete(Index: TIndex); virtual;
    42     procedure DeleteItems(Index, Count: TIndex);
    43     function EqualTo(List: TGMatrix): Boolean;
    4434    procedure Expand;
    45     function Extract(Item: TGMatrixItem): TGMatrixItem;
    4635    procedure Exchange(Index1, Index2: TIndex);
    47     property First: TGMatrixItem read GetFirst write SetFirst;
    4836    procedure FillAll(Value: TGMatrixItem);
    4937    procedure Fill(Start, Count: TIndex; Value: TGMatrixItem);
    5038    function Implode(RowSeparator, ColSeparator: string; Converter: TToStringConverter): string;
    51     procedure Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1);
    52     function IndexOf(Item: TGMatrixItem; Start: TIndex): TIndex;
    53     function IndexOfList(List: TGMatrix; Start: TIndex): TIndex;
    54     procedure Insert(Index: TIndex; Item: TGMatrixItem);
    55     procedure InsertList(Index: TIndex; List: TGMatrix);
    56     procedure InsertArray(Index: TIndex; Values: array of TGMatrixItem);
    57     procedure Move(CurIndex, NewIndex: TIndex);
    58     procedure MoveItems(CurIndex, NewIndex, Count: TIndex);
    5939    procedure Merge(Index: TIndex; Source: TGMatrix; Proc: TMerge);
    6040    procedure Replace(Index: TIndex; Source: TGMatrix);
    61     function Remove(Item: TGMatrixItem): TIndex;
    6241    procedure Reverse;
    6342    procedure ReverseHorizontal;
    6443    procedure ReverseVertical;
    65     procedure Sort(Compare: TSortCompare);
    66     procedure SetArray(Values: array of TGMatrixItem);
    6744    property Count: TIndex read FCount write SetCount;
    6845    property Capacity: TIndex read GetCapacity write SetCapacity;
     
    7148    property Items[Index: TIndex]: TGMatrixItem
    7249      read GetItem write PutItem;
    73     property Last: TGMatrixItem read GetLast write SetLast;
    7450  end;
    7551
     
    7854
    7955{$IFDEF IMPLEMENTATION_USES}
    80 
    81 uses
    82   RtlConsts;
    8356
    8457resourcestring
     
    137110
    138111procedure TGMatrix.SetCapacity(const AValue: TIndex);
    139 var
    140   Y: TGMatrixIndexY;
    141112begin
    142113  if (Capacity.X <> AValue.X) and (Capacity.Y <> AValue.Y) then begin
    143 (*    SetLength(FItems, AValue.Y);
    144     Y := 0;
    145     while Y < Length(FItems) do begin
    146       SetLength(FItems[Y], AValue.X);
    147       Y := Y + 1;
    148     end;
    149   end;
    150   *)
    151114    SetLength(FItems, AValue.Y, AValue.X);
    152115  end;
     
    244207end;
    245208
    246 function TGMatrix.Extract(Item: TGMatrixItem): TGMatrixItem;
    247 var
    248   I: TIndex;
    249 begin
    250 (*  I := IndexOf(Item);
    251   if I >= 0 then begin
    252     Result := Item;
    253     Delete(I);
    254   end else
    255     raise EListError.CreateFmt(SListIndexError, [0]);
    256     *)
    257 end;
    258 
    259 function TGMatrix.IndexOf(Item: TGMatrixItem; Start: TIndex): TIndex;
    260 begin
    261 (*  Result := Start;
    262   while (Result < FCount) and
    263   not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TGMatrixItem)) do
    264     Result := Result + 1;
    265   if Result = FCount then Result := -1;
    266   *)
    267 end;
    268 
    269 procedure TGMatrix.Insert(Index: TIndex; Item: TGMatrixItem);
    270 begin
    271 (*  if (Index < 0) or (Index > FCount ) then
    272     raise EListError.CreateFmt(SListIndexError, [Index]);
    273   if FCount = Capacity then Expand;
    274   if Index < FCount then
    275     System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TGMatrixItem));
    276   FItems[Index] := Item;
    277   FCount := FCount + 1;
    278   *)
    279 end;
    280 
    281 procedure TGMatrix.InsertList(Index: TIndex; List: TGMatrix);
    282 var
    283   I: TIndex;
    284 begin
    285 (*  I := 0;
    286   while (I < List.Count) do begin
    287     Insert(Index + I, List[I]);
    288     I := I + 1;
    289   end;
    290   *)
    291 end;
    292 
    293 function TGMatrix.IndexOfList(List: TGMatrix; Start: TIndex): TIndex;
    294 var
    295   I: TIndex;
    296 begin
    297 (*  if List.Count > 0 then begin
    298     Result := IndexOf(List[0], Start);
    299     if Result <> -1 then begin
    300       I := 1;
    301       while I < List.Count do begin
    302         if not CompareMem(Addr(FItems[Result + I]), Addr(List.FItems[I]), SizeOf(TGMatrixItem)) then begin
    303           Result := -1;
    304           Break;
    305         end;
    306         I := I + 1;
    307       end;
    308     end;
    309   end else Result := -1;
    310   *)
    311 end;
    312 
    313 function TGMatrix.GetLast: TGMatrixItem;
    314 begin
    315 (*  if FCount = 0 then
    316     raise EListError.CreateFmt(SListIndexError, [0])
    317   else
    318     Result := Items[FCount - 1];
    319     *)
    320 end;
    321 
    322 procedure TGMatrix.SetLast(AValue: TGMatrixItem);
    323 begin
    324 (*  if FCount = 0 then
    325     raise EListError.CreateFmt(SListIndexError, [0])
    326   else
    327     Items[FCount - 1] := AValue;
    328     *)
    329 end;
    330 
    331 function TGMatrix.GetFirst: TGMatrixItem;
    332 begin
    333 (*  if FCount = 0 then
    334     raise EListError.CreateFmt(SListIndexError, [0])
    335   else
    336     Result := Items[0];
    337     *)
    338 end;
    339 
    340 procedure TGMatrix.SetFirst(AValue: TGMatrixItem);
    341 begin
    342 (*  if FCount = 0 then
    343     raise EListError.CreateFmt(SListIndexError, [0])
    344   else
    345     Items[0] := AValue;
    346     *)
    347 end;
    348 
    349 procedure TGMatrix.Move(CurIndex, NewIndex: TIndex);
    350 var
    351   Temp: TGMatrixItem;
    352 begin
    353 (*  if ((CurIndex < 0) or (CurIndex > Count - 1)) then
    354     raise EListError.CreateFmt(SListIndexError, [CurIndex]);
    355   if ((NewIndex < 0) or (NewIndex > Count -1)) then
    356     raise EListError.CreateFmt(SlistIndexError, [NewIndex]);
    357   Temp := FItems[CurIndex];
    358   if NewIndex > CurIndex then begin
    359     System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(TGMatrixItem));
    360   end else
    361   if NewIndex < CurIndex then begin
    362     System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(TGMatrixItem));
    363   end;
    364   FItems[NewIndex] := Temp;
    365   //Delete(CurIndex);
    366   //Insert(NewIndex, Temp);*)
    367 end;
    368 
    369 procedure TGMatrix.MoveItems(CurIndex, NewIndex, Count: TIndex);
    370 var
    371   S: Integer;
    372   D: Integer;
    373 begin
    374 (*  if CurIndex < NewIndex then begin
    375     S := CurIndex + Count - 1;
    376     D := NewIndex + Count - 1;
    377     while S >= CurIndex do begin
    378       Move(S, D);
    379       S := S - 1;
    380       D := D - 1;
    381     end;
    382   end else
    383   if CurIndex > NewIndex then begin
    384     S := CurIndex;
    385     D := NewIndex;
    386     while S < (CurIndex + Count) do begin
    387       Move(S, D);
    388       S := S + 1;
    389       D := D + 1;
    390     end;
    391   end;*)
    392 end;
    393 
    394 function TGMatrix.Remove(Item: TGMatrixItem): TIndex;
    395 begin
    396 (*  Result := IndexOf(Item);
    397   if Result <> -1 then
    398     Delete(Result); *)
    399 end;
    400 
    401 function TGMatrix.EqualTo(List: TGMatrix): Boolean;
    402 var
    403   I: TIndex;
    404 begin
    405 (*  Result := Count = List.Count;
    406   if Result then begin
    407     I := 0;
    408     while I < Count do begin
    409       if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(TGMatrixItem)) then begin
    410         Result := False;
    411         Break;
    412       end;
    413       I := I + 1;
    414     end;
    415   end; *)
    416 end;
    417 
    418209procedure TGMatrix.Reverse;
    419210var
     
    464255end;
    465256
    466 procedure TGMatrix.Sort(Compare: TSortCompare);
    467 begin
    468 (*  if FCount > 1 then
    469     QuickSort(0, FCount - 1, Compare); *)
    470 end;
    471 
    472 procedure TGMatrix.AddMatrix(Values: array of TRow);
    473 var
    474   I: TIndex;
    475 begin
    476 (*  I := 0;
    477   while I <= High(Values) do begin
    478     Add(Values[I]);
    479     I := I + 1;
    480   end; *)
    481 end;
    482 
    483 procedure TGMatrix.SetArray(Values: array of TGMatrixItem);
    484 var
    485   I: TIndex;
    486 begin
    487 (*  Clear;
    488   I := 0;
    489   while I <= High(Values) do begin
    490     Add(Values[I]);
    491     I := I + 1;
    492   end; *)
    493 end;
    494 
    495 procedure TGMatrix.InsertArray(Index: TIndex; Values: array of TGMatrixItem);
    496 var
    497   I: TIndex;
    498 begin
    499 (*  I := 0;
    500   while I <= High(Values) do begin
    501     Insert(Index + I, Values[I]);
    502     I := I + 1;
    503   end; *)
    504 end;
    505 
    506257function TGMatrix.Implode(RowSeparator, ColSeparator: string; Converter: TToStringConverter): string;
    507258var
     
    525276end;
    526277
    527 procedure TGMatrix.Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1);
    528 begin
    529 (*  Clear;
    530   while (Pos(Separator, Text) > 0) and
    531   ((Count < (SlicesCount - 1)) or (SlicesCount = -1)) do begin
    532     Add(Converter(Copy(Text, 1, Pos(Separator, Text) - 1)));
    533     System.Delete(Text, 1, Pos(Separator, Text) + Length(Separator) - 1);
    534   end;
    535   Add(Converter(Text)); *)
    536 end;
    537 
    538 function TGMatrix.Add(Item: TGMatrixItem): TIndex;
    539 begin
    540 (*  if FCount = Capacity then
    541     Self.Expand;
    542   FItems[FCount] := Item;
    543   Result := FCount;
    544   FCount := FCount + 1; *)
    545 end;
    546 
    547 procedure TGMatrix.AddList(List: TGMatrix);
    548 var
    549   I: TIndex;
    550 begin
    551 (*  I := 0;
    552   while I < List.Count do begin
    553     Add(List[I]);
    554     I := I + 1;
    555   end; *)
    556 end;
    557 
    558278procedure TGMatrix.Clear;
    559279begin
    560280  Count := CreateIndex(0, 0);
    561281  Capacity := CreateIndex(0, 0);
    562 end;
    563 
    564 procedure TGMatrix.Delete(Index: TIndex);
    565 begin
    566 (*  if (Index < 0) or (Index >= FCount) then
    567     raise EListError.CreateFmt(SListIndexError, [Index]);
    568   FCount := FCount - 1;
    569   System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TGMatrixItem));
    570   Contract;
    571   *)
    572 end;
    573 
    574 procedure TGMatrix.DeleteItems(Index, Count: TIndex);
    575 var
    576   I: TIndex;
    577 begin
    578 (*  I := Index;
    579   while I < (Index + Count) do begin
    580     Delete(Index);
    581     I := I + 1;
    582   end;
    583   *)
    584282end;
    585283
  • trunk/Packages/TemplateGenerics/Generic/GenericPoint.inc

    r57 r324  
    22
    33// TGPoint<TPointType> = class
    4 TGPoint = class
     4TGPoint = record
    55  X: TGPointType;
    66  Y: TGPointType;
  • trunk/Packages/TemplateGenerics/ReadMe.txt

    r264 r324  
    22=================
    33
    4 Tutorial and basic information:
    5   http://wiki.freepascal.org/Templates
     4Tutorial and basic information: http://wiki.freepascal.org/Templates
    65
    7 Version: 0.3
    8 Release date: 2011-01-01
     6Version: 0.4
     7Release date: 2024-06-25
    98Author: Chronos
    109Email: robie@centrum.cz
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedBitmap.pas

    r57 r324  
    1   unit SpecializedBitmap;
    2 
    3 {$mode Delphi}{$H+}
     1unit SpecializedBitmap;
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedDictionary.pas

    r57 r324  
    11unit SpecializedDictionary;
    2 
    3 {$mode delphi}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedList.pas

    r57 r324  
    11unit SpecializedList;
    2 
    3 {$mode delphi}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedMatrix.pas

    r57 r324  
    11unit SpecializedMatrix;
    2 
    3 {$mode objfpc}{$H+}
    42
    53interface
    64
    75uses
    8   Classes, SysUtils; 
     6  Classes, SysUtils;
    97
    108type
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedPoint.pas

    r57 r324  
    11unit SpecializedPoint;
    2 
    3 {$mode objfpc}{$H+}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedQueue.pas

    r57 r324  
    11unit SpecializedQueue;
    2 
    3 {$mode delphi}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedRectangle.pas

    r57 r324  
    11unit SpecializedRectangle;
    2 
    3 {$mode Delphi}{$H+}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedSet.pas

    r57 r324  
    11unit SpecializedSet;
    2 
    3 {$mode delphi}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedStack.pas

    r57 r324  
    11unit SpecializedStack;
    2 
    3 {$mode delphi}
    42
    53interface
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedStream.pas

    r57 r324  
    11unit SpecializedStream;
    2 
    3 {$mode delphi}
    42
    53interface
     
    113111function TMemoryStreamByte.WriteBuffer(var Buffer; Count: Integer): Integer;
    114112begin
    115 
     113  Result := 0;
    116114end;
    117115
     
    137135function TMemoryStreamByte.ReadBuffer(var Buffer; Count: Integer): Integer;
    138136begin
    139 
     137  Result := 0;
    140138end;
    141139
     
    143141  ): Integer;
    144142begin
    145 
     143  Result := 0;
    146144end;
    147145
  • trunk/Packages/TemplateGenerics/Specialized/SpecializedTree.pas

    r57 r324  
    11unit SpecializedTree;
    2 
    3 {$mode delphi}
    42
    53interface
  • trunk/Packages/TemplateGenerics/TemplateGenerics.lpk

    r177 r324  
    1717      <Parsing>
    1818        <SyntaxOptions>
     19          <SyntaxMode Value="Delphi"/>
    1920          <CStyleOperator Value="False"/>
    2021          <AllowLabel Value="False"/>
     
    151152      </Item27>
    152153      <Item28>
    153         <Filename Value="Additional\UBinarySerializer.pas"/>
    154         <UnitName Value="UBinarySerializer"/>
     154        <Filename Value="Additional\BinarySerializer.pas"/>
     155        <UnitName Value="BinarySerializer"/>
    155156      </Item28>
    156157    </Files>
  • trunk/Packages/TemplateGenerics/TemplateGenerics.pas

    r57 r324  
    55unit TemplateGenerics;
    66
     7{$warn 5023 off : no warning about unused units}
    78interface
    89
     
    1112  SpecializedQueue, SpecializedSet, SpecializedPoint, SpecializedMatrix,
    1213  SpecializedBitmap, SpecializedStream, SpecializedRectangle,
    13   UBinarySerializer, LazarusPackageIntf;
     14  BinarySerializer, LazarusPackageIntf;
    1415
    1516implementation
Note: See TracChangeset for help on using the changeset viewer.