CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

STL binary_search() help



I have this problem trying to search for a value  in a vector of objects.
For example , I have

class Base
{
 public :
                AnsiString First;
               AnsiString Second;
};


vector<Base> vt;
I need to run search based only on First, disregarding whatever value of
the second might be.
Doing     binary_search(vt.begin(), vt.end(), SearchValue)  doesn't work of
course. ( SearchValue is AnsiString);
I tried  :
             vector<Base>::iterator i = vt.begin();
             vector<Base>::iterator j = vt.end();
binary_search(i->First, j->First, SearchValue)  --> doesn't work either.

Any ideas would be greatly appreciated.

P.S  if you want to advise me to use TStrings or TList please do not reply.




W Komornicki's Home Page | Main Index | Thread Index