[fpc-devel] TFPHashList and FindIndexOf

Seth Grover sethdgrover at gmail.com
Thu Apr 7 17:02:05 CEST 2011


After some debugging into a problem I was finding, I determined that
TFPHashList.FindIndexOf only works of the Key has non-nil data
associated with it. In other words:

list.Add('abcd', nil);
result := list.FindIndexOf('abcd');

In that case, result will be -1, because the InternalFind procedure
only returns a value "if assigned(Data)".

I think this is wrong behavior, or at least it's documented wrong. The
documentation says:

"FindIndexOf returns the index of the key AName, or -1 if the key does
not exist in the list. It uses the hash value to search for the key."

Well, the key DOES exist in the list... it's just associated with nil data.

Should I log a bug? Or is this really how it's supposed to work?

-SG

--
This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.

Seth Grover
sethdgrover[at]gmail[dot]com



More information about the fpc-devel mailing list