No, but I have the opposite:
{$ifdef fpc}{$mode delphi}{$H+}{$endif}
uses
generics.collections;
Type
TIntegerMap = TDictionary<integer,integer>;
var
C:TIntegerMap;
K,V:array of integer;
i:integer;
begin
C:= TIntegerMap.Create;
try
C.Add(100,102);
C.Add(103,104);
// edit for comment: this is all...
K := C.keys.ToArray;
V := C.values.ToArray;
// The rest of the code in both examples is the same.
finally
for i in K do write('Key':8,i:8); // dump keys
writeln;
for i in V do write('Value':8,i:8); // dump values
C.free;
end;
end.
That's:
- a: Delphi compatible
- b: also available for FPC 3.0.4 through Maciej's website. (but it is in trunk as standard)
- c: really fast.
[EDIT]
Ok, same code for FGL (not!!!!! recommended, but almost just as easy to write except you have to write the loop yourself):
{$ifdef fpc}{$mode delphi}{$H+}{$endif}
uses fgl;
type
TIntegerMap = TFPGMap<integer, integer>;
var
C:TIntegerMap;
K,V:array of integer;
I:integer;
begin
c := TIntegermap.Create;
try
c.Add(100,102);
c.Add(103,104);
// edit for comment: set the size of the arrays, and write the loop..
Setlength(K, c.Count);
Setlength(V, c.count);
for i := 0 to c.count-1 do
begin
K[i] := c.Keys[i];
V[i] := c.data[i];
end;
// The rest of the code in both examples is the same.
finally
for i in k do write('Key':8,i:8); // dump keys
writeln;
for i in v do write('Value':8,i:8); // dump values
c.Free;
end;
end.
Usually I ignore such questions from"programmers" that are not noobs. If you don't know how to read the headers from FGL .... or write a loop... you are really not a programmer. < very grumpy
>.
Laziness is not an excuse and plz follow sound advice.