Unimatrix_001
asked on
Searching a vector for a vector.
Hi,
Is there some STL method that lets me search a vector of values from a certain index for another vector of values and telling me the returned index?
Thanks,
Uni
Is there some STL method that lets me search a vector of values from a certain index for another vector of values and telling me the returned index?
Thanks,
Uni
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Obviously in the second code sample, pattern should have been replaced by match :
std::vector<int> vec; // <--- the vector
std::vector<int> match; // <--- the values we want to find
std::vector<int>::iterator it = find_first_of(vec.begin(), vec.end(), match.begin(), match.end());
if (it != vec.end()) {
// found a match at iterator it
}
ASKER
That's the one. :)
http://www.cplusplus.com/reference/algorithm/find_first_of.html
Open in new window