template<class FORWARD_ITR_NEEDLE, class EQUAL = bsl::equal_to< typename bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>>
class bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >
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().
See bslstl_defaultsearcher
template<class FORWARD_ITR_NEEDLE , class EQUAL >
template<class FORWARD_ITR_HAYSTACK >
| bsl::pair< FORWARD_ITR_HAYSTACK, FORWARD_ITR_HAYSTACK > bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::operator() |
( |
FORWARD_ITR_HAYSTACK |
haystackFirst, |
|
|
FORWARD_ITR_HAYSTACK |
haystackLast |
|
) |
| const |
|
inline |
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(haystackFirst, haystackLast);
FORWARD_ITR_NEEDLE needleFirst() const
Definition bslstl_defaultsearcher.h:747
FORWARD_ITR_NEEDLE needleLast() const
Definition bslstl_defaultsearcher.h:755
Values of the "needle" sequence and the "haystack" sequence are compared using the equality comparison functor specified on construction.
- Precondition
- 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
- 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.