I have a vector of pairs vector< pair< string,int> > in C++ and i want to lower_bound on string value but with additional constraint that the second value of pair should be less than or equal to a given value. Currently i am doing it using a compare template
bool compare(const T &a,const T &b){
if (a.first<=b.first&&b.second<=a.second) return true;
}
but it is not working properly. The vector is sorted according to the first value of pair. Example->The vector has following contents:
abcd,1
abcde,4
abcdex,3
abce,2
and i want to lower_bound on abc,3 so it should return abcd,1 but it is returning abcdex,3.Please help.
Aucun commentaire:
Enregistrer un commentaire