[fpc-pascal] fgl unit bug in generic class TFPGMap

Flávio Etrusco flavio.etrusco at gmail.com
Sun Oct 26 05:51:45 CET 2014


On Fri, Oct 3, 2014 at 12:42 PM, Dennis Poon <dennis at 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.

-Flávio



More information about the fpc-pascal mailing list