[#BloombergLP-bslstl-DefaultSearcher]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::DefaultSearcher
:relfileprefix: ../../
:mrdocs:

This class template defines functors that can search for the sequence of `value&lowbar;type` values defined on construction (i&period;e&period;, the &quot;needle&quot;) in sequences of `value&lowbar;type` values (i&period;e&period;, &quot;haystacks&quot;) passed to the functor&apos;s `operator()`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;defaultsearcher&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class FORWARD&lowbar;ITR&lowbar;NEEDLE,
    class EQUAL = xref:bsl/equal_to-0d.adoc[bsl::equal&lowbar;to&lt;bsl::iterator&lowbar;traits&lt;FORWARD&lowbar;ITR&lowbar;NEEDLE&gt;::value&lowbar;type&gt;]&gt;
class DefaultSearcher;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/DefaultSearcher/2constructor.adoc[`DefaultSearcher`]         [.small]#[constructor]#
| Create a `DefaultSearcher` object that can search for the sequence of `value&lowbar;type` values found in the specified range `&lsqb;needleFirst, needleLast)&rsqb;`&period; Optionally supply an `equal` functor for use by `operator()`&period; The behavior is undefined unless `needleFirst` can be advanced to equal `needleLast`&period;
| xref:BloombergLP/bslstl/DefaultSearcher/equal.adoc[`equal`] 
| Return the functor used by this searcher object to compare `value&lowbar;type` values&period;
| xref:BloombergLP/bslstl/DefaultSearcher/needleFirst.adoc[`needleFirst`] 
| Return an iterator referring to the first element of the sequence of `value&lowbar;type` values that can be sought by this searcher object&period;
| xref:BloombergLP/bslstl/DefaultSearcher/needleLast.adoc[`needleLast`] 
| Return an iterator referring to one past the last element of the sequence of `value&lowbar;type` values that can be sought by this searcher object&period;
| xref:BloombergLP/bslstl/DefaultSearcher/operator_call.adoc[`operator()`] 
| Search the specified range `&lsqb;haystackFirst, haystackLast)&rsqb;` for the first sequence of `value&lowbar;type` values specified on construction&period; Return the range where those values are found, or the range `&lsqb;haystackLast, haystackLast)&rsqb;` if that sequence is not found&period; The search is performed using a &quot;naive&quot; algorithm that has time complexity of&colon; &grave; bsl&colon;&colon;distance(needleFirst(), needleLast()) &ast; bsl&colon;&colon;distance(haystackFirst, haystackLast)&semi; &grave; Values of the &quot;needle&quot; sequence and the &quot;haystack&quot; sequence are compared using the equality comparison functor specified on construction&period; The behavior is undefined unless `haystackFirst` can be advanced to equal `haystackLast` and the iterators used to construct this object, `needleFirst()` and `needleLast()`, are still valid&period; Note that if the &quot;needle&quot; sequence is empty, the range `&lsqb;haystackFirst, haystackFirst)&rsqb;` is returned&period; Also note that if the &quot;needle&quot; sequence is longer than the &quot;haystack&quot; sequence &hyphen;&hyphen; thus, impossible for the &quot;needle&quot; to be found in the &quot;haystack&quot; &hyphen;&hyphen; the range `&lsqb;haystackLast, haystackLast)&rsqb;` is returned&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
