search [C++ Reference]
Keywords: stl,algorithm,search
Date: 2009-10-09T01:03:41-0700

[[search]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## search

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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •