Bob Ebert wrote:
> SysBinarySearch changed in the 3.1 release. (or maybe it was the 3.0
> release... I forget, I'm getting old.)
>
> The older version had several bugs, one of them is the one you describe.
>
> If you want a reliable binary search, just put the code from the new
> SysBinarySearch into your own app, or (even better), write your own binary
> search routine based on the algorithm below. (You can improve performance
> a lot by de-generalizing the routine, e.g. getting rid of the
> call back for the test.)
Thanks for the information Bob. Your reply leads to a few questions:
1. You say the old version had "several bugs". What other bugs am I likely
to encounter?
2. If SysBinarySearch has known bugs, why is there no mention of them in the
documentation? I went to
http://www.palm.com/devzone/docs/palmos/CombinedTOC.html and looked it up,
but found no mention of known bugs or the OS versions in which they were
fixed. Bugs happen, and I'm not trying to blame anyone, but developers
should at least be able to find out about known bugs. Is there another web
page where this type of information is available?
3. I posted my fix at the end of my post. After doing the search, I do this:
if (pp_array[searchpos].id != id) searchpos--; // are we one too far?
If the element at the returned position does not match what I'm looking for,
I just back up one position. That SEEMS to fix my problem. Based on what you
know, is this a valid fix? Or have I just been lucky so far? If there's a
binary search routine built into the OS, I'd rather use it than write my
own, in order to keep my code as small as possible.
Thanks again!
Tom Ward