Difference between revisions of "TFPGMap"

From Lazarus wiki
Jump to navigationJump to search
(see also)
Line 1: Line 1:
TFpGMap is part of the Free Generics Library
+
TFPGMap is part of the <code>FGL</code> (Free Generics Library).
  
Here is an example provided by forum user Remy Lebeau
+
Here is an example provided by forum user '''Remy Lebeau''':
  
    uses
+
<syntaxhighlight lang="pascal">
      ..., fgl;
+
uses
   
+
  ..., fgl;
    var
+
      Dict: TFPGMap<string, integer>;
+
var
      Value: Integer;
+
  Dict: TFPGMap<string, integer>;
    begin
+
  Value: Integer;
      Dict := TFPGMap<string, integer>.Create;
+
begin
      try
+
  Dict := TFPGMap<string, integer>.Create;
        Dict.Add('VarName', 99);
+
  try
        ...
+
    Dict.Add('VarName', 99);
        Value := Dict['VarName'];
+
    ...
        ...
+
    Value := Dict['VarName'];
      finally
+
    ...
        Dict.Free;
+
  finally
      end;
+
    Dict.Free;
    end;
+
  end;
 +
end;
 +
</syntaxhighlight>
  
==See Also==
+
==See also==
  
 
* https://www.freepascal.org/docs-html/current/rtl/fgl/tfpgmap.html
 
* https://www.freepascal.org/docs-html/current/rtl/fgl/tfpgmap.html

Revision as of 18:35, 13 November 2022

TFPGMap is part of the FGL (Free Generics Library).

Here is an example provided by forum user Remy Lebeau:

uses
  ..., fgl;
 
var
  Dict: TFPGMap<string, integer>;
  Value: Integer;
begin
  Dict := TFPGMap<string, integer>.Create;
  try
    Dict.Add('VarName', 99);
    ...
    Value := Dict['VarName'];
    ...
  finally
    Dict.Free;
  end;
end;

See also