Quick Links:

bal | bbl | bdl | bsl

Static Public Member Functions

bslstl::DefaultSearcher_ImpUtil Struct Reference

#include <bslstl_defaultsearcher.h>

List of all members.

Static Public Member Functions

template<class FORWARD_ITR_NEEDLE , class EQUAL , class FORWARD_ITR_HAYSTACK >
static bsl::enable_if
< DefaultSearcher_CanOptimize
< FORWARD_ITR_NEEDLE, EQUAL,
FORWARD_ITR_HAYSTACK >::value,
bsl::pair
< FORWARD_ITR_HAYSTACK,
FORWARD_ITR_HAYSTACK > >::type 
doSearch (const FORWARD_ITR_HAYSTACK &haystackFirst, const FORWARD_ITR_HAYSTACK &haystackLast, const FORWARD_ITR_NEEDLE &needleFirst, const FORWARD_ITR_NEEDLE &needleLast, const EQUAL &equal)
template<class FORWARD_ITR_NEEDLE , class EQUAL , class FORWARD_ITR_HAYSTACK >
static bsl::enable_if
<!DefaultSearcher_CanOptimize
< FORWARD_ITR_NEEDLE, EQUAL,
FORWARD_ITR_HAYSTACK >::value,
bsl::pair
< FORWARD_ITR_HAYSTACK,
FORWARD_ITR_HAYSTACK > >::type 
doSearch (const FORWARD_ITR_HAYSTACK &haystackFirst, const FORWARD_ITR_HAYSTACK &haystackLast, const FORWARD_ITR_NEEDLE &needleFirst, const FORWARD_ITR_NEEDLE &needleLast, const EQUAL &equal)

Detailed Description

This component-private utility struct provides two mutually exclusive overloads of the doSearch method -- i.e., just one of the two methods is enabled at any time. Enablement is decided by the DefaultSearcher_CanOptimize meta-function.

See Component bslstl_defaultsearcher


Member Function Documentation

template<class FORWARD_ITR_NEEDLE , class EQUAL , class FORWARD_ITR_HAYSTACK >
static bsl::enable_if< DefaultSearcher_CanOptimize<FORWARD_ITR_NEEDLE, EQUAL, FORWARD_ITR_HAYSTACK>::value , bsl::pair<FORWARD_ITR_HAYSTACK, FORWARD_ITR_HAYSTACK> >::type bslstl::DefaultSearcher_ImpUtil::doSearch ( const FORWARD_ITR_HAYSTACK &  haystackFirst,
const FORWARD_ITR_HAYSTACK &  haystackLast,
const FORWARD_ITR_NEEDLE &  needleFirst,
const FORWARD_ITR_NEEDLE &  needleLast,
const EQUAL &  equal 
) [static]
template<class FORWARD_ITR_NEEDLE , class EQUAL , class FORWARD_ITR_HAYSTACK >
static bsl::enable_if<!DefaultSearcher_CanOptimize<FORWARD_ITR_NEEDLE, EQUAL, FORWARD_ITR_HAYSTACK>::value , bsl::pair<FORWARD_ITR_HAYSTACK, FORWARD_ITR_HAYSTACK> >::type bslstl::DefaultSearcher_ImpUtil::doSearch ( const FORWARD_ITR_HAYSTACK &  haystackFirst,
const FORWARD_ITR_HAYSTACK &  haystackLast,
const FORWARD_ITR_NEEDLE &  needleFirst,
const FORWARD_ITR_NEEDLE &  needleLast,
const EQUAL &  equal 
) [static]

Search the specified "haystack" sequence of value_type values, [haystackFirst, hastackLast), for the specified "needle" sequence of value_type values, [needleFirst, needleLast) where the value_type values are compared using the specified equal functor. Return the range where the sought sequence of 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" sequences are compared using the equality comparison functor specified on construction except, possibly, if the DefaultSearcher_CanOptimize metafunction indicates that the template parameters are eligible for optimization. The optimized overload is enabled when needle and haystack can be validly compared using std::memcmp, a low-level function that is often highly optimized for its platform. The behavior is undefined unless haystackFirst can be advanced to equal haystackLast. 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.


The documentation for this struct was generated from the following file: