Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-04

TFPHashList and FindIndexOf

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Seth Grover

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

Reply by email