I’ve got a node struct
struct Node{CString text, int id;};
in a sorted vector.
I’m wondering if there’s a function in algorithm that will do a binary search of the vector and find an element.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
std::binary_search()will tell you if a value exists in the container.std::lower_bound()/std::upper_bound()will return an iterator to the first/last occurrence of a value.Your objects need to implement
operator<for these algorithms to work.