Syntax:
#include <algorithm> forward_iterator search( forward_iterator start1, forward_iterator end1, forward_iterator2 start2, forward_iterator2 end2 ); forward_iterator search( forward_iterator start1, forward_iterator end1, forward_iterator2 start2, forward_iterator2 end2, BinPred p );
The search() algorithm looks for the elements [start2,end2) in the range [start1,end1). If the optional binary predicate p is provided, then it is used to perform comparisons between elements.
If search() finds a matching subrange, then it returns an iterator to the beginning of that matching subrange. If no match is found, an iterator pointing to end1 is returned.
In the worst case, search() runs in quadratic time, on average, it runs in linear time.
Related Topics: equal, find, lexicographical_compare, mismatch, search_n