Quick Links: |
#include <bslstl_defaultsearcher.h>
Public Member Functions | |
DefaultSearcher (FORWARD_ITR_NEEDLE needleFirst, FORWARD_ITR_NEEDLE needleLast, EQUAL equal=EQUAL()) | |
DefaultSearcher (const DefaultSearcher &original) | |
DefaultSearcher (DefaultSearcher &&original) | |
~DefaultSearcher () | |
DefaultSearcher & | operator= (const DefaultSearcher &rhs) |
DefaultSearcher & | operator= (DefaultSearcher &&rhs) |
template<class FORWARD_ITR_HAYSTACK > | |
bsl::pair < FORWARD_ITR_HAYSTACK, FORWARD_ITR_HAYSTACK > | operator() (FORWARD_ITR_HAYSTACK haystackFirst, FORWARD_ITR_HAYSTACK haystackLast) const |
FORWARD_ITR_NEEDLE | needleFirst () const |
FORWARD_ITR_NEEDLE | needleLast () const |
EQUAL | equal () const |
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 Component bslstl_defaultsearcher
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::DefaultSearcher | ( | FORWARD_ITR_NEEDLE | needleFirst, | |
FORWARD_ITR_NEEDLE | needleLast, | |||
EQUAL | equal = EQUAL() | |||
) |
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
.
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::DefaultSearcher | ( | const DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > & | original | ) |
Create a DefaultSearcher
object that has the same state as the specified original
object.
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::DefaultSearcher | ( | DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > && | original | ) |
Create a DefaultSeacher
object having the same state as the specified original
object. The original
object is left in an unspecified (valid) state.
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::~DefaultSearcher | ( | ) |
Destroy this DefaultSearcher
object.
DefaultSearcher& bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::operator= | ( | const DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > & | rhs | ) |
Assign to this object the state of the specified rhs
object, and return a non-'const' reference to this object.
DefaultSearcher& bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::operator= | ( | DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > && | rhs | ) |
Assign to this object the state of the specified rhs
had and return a non-'const' reference to this object. The original
object is left in an unspecified (valid) state.
bsl::pair<FORWARD_ITR_HAYSTACK, FORWARD_ITR_HAYSTACK> bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::operator() | ( | FORWARD_ITR_HAYSTACK | haystackFirst, | |
FORWARD_ITR_HAYSTACK | haystackLast | |||
) | const |
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.
FORWARD_ITR_NEEDLE bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::needleFirst | ( | ) | const |
Return an iterator referring to the first element of the sequence of value_type
values that can be sought by this searcher object.
FORWARD_ITR_NEEDLE bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::needleLast | ( | ) | const |
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.
EQUAL bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::equal | ( | ) | const |
Return the functor used by this searcher object to compare value_type
values.