Hi folks.
For some reason I am trying to use fgl.TFPGMap instead of generics.collection.TDictionary. It seemed to me that the TFPSMap.IndexOfData function was not working properly. Here is an example code that reproduces the issue.
uses
...fgl...;
type
TMyTest = specialize TFPGMap<PtrInt,String>;
...
public
property MyTest: TMyTest read FMyTest write SetMyTest;
end;
...
var
i: PtrInt = 0;
begin
FMyTest:= TMyTest.Create;
for i:= 0 to 9 do
MyTest.AddOrSetData(i,Format('string_%d (added as Object: %d)',[Succ(i),i]));;
ComboBox1.Clear;
for i:= 0 to Pred(MyTest.Count) do
ComboBox1.Items.Add(MyTest.Data[i]);
ComboBox1.ItemIndex:= 0;
ComboBox1Change(Sender);
...
procedure TForm1.ComboBox1Change(Sender: TObject);
var
k: PtrInt = 0;
begin
Label1.Caption:= 'no matches';
k:= MyTest.IndexOfData(ComboBox1.Items[ComboBox1.ItemIndex]);
if (k > -1) then
Label1.Caption:= 'Key: ' + IntToStr(MyTest.Keys[k]);
Caption:= IntToStr(MyTest.Count);
end;
Plz someone confirm my guess