How about using a binary search, and coding the record comparison
function to look at both the class and the product (giving more weight to
the class).  Then you could make a temporary record with the class that the
user chose, and a product code of 1.  The location you get back from the
binary search should be at or within 1 record of the start of the class
(depending on whether a product code of 1 actually exists in the chosen
class).
    -- Stephen


-- 
Please remove no and spam from my email address if replying by email.


"Desenvolvimento 3" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi folks,

What�s the best way to perform a search on a pdb? I like to use the binary
search algorithm but this one looks not so much efficient to solve my
problem.
I have a list with several products inside that are ordened by their product
class. When the user selects choose one class I must show him all products.
I tried the sequencial search but it is horrible, now I am triyng the binary
but when the code makes its division it may or not get ther first product of
my class, than I have to run back to find the first one. It is not good to.

ex.:
class  product
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3

the binary search will divide this list on the 4th item, even I found the
right product of my class I must run back to the first product by
comparision.

Does anybody have some ideas?

thank you very much



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to