search

C/C++ Reference

search
Syntax:
  #include <algorithm>
  iterator search( iterator start1, iterator end1, iterator start2, iterator end2 );
  iterator search( iterator start1, iterator end1, iterator start2, iterator 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: