[#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_type` values defined on construction (i.e., the "needle") in sequences of `value_type` values (i.e., "haystacks") passed to the functor's `operator()`. == Synopsis Declared in `<bslstl_defaultsearcher.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class FORWARD_ITR_NEEDLE, class EQUAL = xref:bsl/equal_to-0d.adoc[bsl::equal_to<bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>]> 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_type` values found in the specified range `[needleFirst, needleLast)]`. Optionally supply an `equal` functor for use by `operator()`. The behavior is undefined unless `needleFirst` can be advanced to equal `needleLast`. | xref:BloombergLP/bslstl/DefaultSearcher/equal.adoc[`equal`] | Return the functor used by this searcher object to compare `value_type` values. | xref:BloombergLP/bslstl/DefaultSearcher/needleFirst.adoc[`needleFirst`] | Return an iterator referring to the first element of the sequence of `value_type` values that can be sought by this searcher object. | xref:BloombergLP/bslstl/DefaultSearcher/needleLast.adoc[`needleLast`] | Return an iterator referring to one past the last element of the sequence of `value_type` values that can be sought by this searcher object. | xref:BloombergLP/bslstl/DefaultSearcher/operator_call.adoc[`operator()`] | Search the specified range `[haystackFirst, haystackLast)]` for the first sequence of `value_type` values specified on construction. Return the range where those values are found, or the range `[haystackLast, haystackLast)]` if that sequence is not found. The search is performed using a "naive" algorithm that has time complexity of: ` bsl::distance(needleFirst(), needleLast()) * bsl::distance(haystackFirst, haystackLast); ` Values of the "needle" sequence and the "haystack" sequence are compared using the equality comparison functor specified on construction. 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. Note that if the "needle" sequence is empty, the range `[haystackFirst, haystackFirst)]` is returned. Also note that if the "needle" sequence is longer than the "haystack" sequence ‐‐ thus, impossible for the "needle" to be found in the "haystack" ‐‐ the range `[haystackLast, haystackLast)]` is returned. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#