Am 26.10.2014 05:51, schrieb Flávio Etrusco:
On Fri, Oct 3, 2014 at 12:42 PM, Dennis Poon <den...@avidsoft.com.hk> wrote:
I think I found a bug in TFPGMap.
Hope some of you can verify it.
The bug seems to relate to the binary search used in the method "FIND" but
it does not occur for all string key values or at all capacity of the map.
Seems only occur at the second item added and when it is certain string
values.
I tried to debug it but cannot step into the codes of fgl unit so cannot
find the cause.
Please help.
Dennis
=====================
unit Unit1;
(...)
TMapOfObjects=class(specialize TFPGMap < String, TObject> )
(...)
I don't see any calls to 'Sort' or 'Sorted' in your code. 'Find', as
you note, does a binary search thus expects the items to be sorted.
You can also use 'IndexOf' instead.
But a map should not need any call to Sort, because it's the map's task
to organize its data structure in such a way that Find does work as it
should.
Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal