You are not logged in.
Pages: 1
Arnaud, what is the best approach to get keys and values from a TSynDictionary instance?
I have a dictionary where the keys are Double and the values are integers. My objective is get the count of integers by key. And I am using this:
My HugeList[] is a TDoubleDynArray:
D := TSynDictionary.Create(TypeInfo(TDoubleDynArray), TypeInfo(TIntegerDynArray));
try
for I := 0 to High(HugeList) do begin
if D.FindAndCopy(HugeList[I], N) then
N := N + 1
else
N := 1;
D.AddOrUpdate(HugeList[I], N);
end;
SetLength(Keys, D.Keys.Count); // get a copy of the keys <--- this works, but
D.Keys.Slice(Keys, D.Keys.Count);
SetLength(Counts, D.Values.Count); // get a copy of the values <--- there are a better way?
D.Values.Slice(Counts, D.Values.Count);
finally
D.Free;
end;
Offline
Yeah that works. Thank you.
Offline
Pages: 1