BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > Class Template Reference

#include <bslstl_defaultsearcher.h>

Public Member Functions

 DefaultSearcher (FORWARD_ITR_NEEDLE needleFirst, FORWARD_ITR_NEEDLE needleLast, EQUAL equal=EQUAL())
 
 DefaultSearcher (const DefaultSearcher &original)=default
 
 DefaultSearcher (DefaultSearcher &&original)=default
 
 ~DefaultSearcher ()=default
 Destroy this DefaultSearcher object.
 
DefaultSearcheroperator= (const DefaultSearcher &rhs)=default
 
DefaultSearcheroperator= (DefaultSearcher &&rhs)=default
 
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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ DefaultSearcher() [1/3]

template<class FORWARD_ITR_NEEDLE , class EQUAL >
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::DefaultSearcher ( FORWARD_ITR_NEEDLE  needleFirst,
FORWARD_ITR_NEEDLE  needleLast,
EQUAL  equal = EQUAL() 
)
inline

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.

◆ DefaultSearcher() [2/3]

template<class FORWARD_ITR_NEEDLE , class EQUAL = bsl::equal_to< typename bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>>
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::DefaultSearcher ( const DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > &  original)
default

Create a DefaultSearcher object that has the same state as the specified original object.

◆ DefaultSearcher() [3/3]

template<class FORWARD_ITR_NEEDLE , class EQUAL = bsl::equal_to< typename bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>>
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::DefaultSearcher ( DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > &&  original)
default

Create a DefaultSeacher object having the same state as the specified original object. The original object is left in an unspecified (valid) state.

◆ ~DefaultSearcher()

template<class FORWARD_ITR_NEEDLE , class EQUAL = bsl::equal_to< typename bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>>
bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::~DefaultSearcher ( )
default

Member Function Documentation

◆ equal()

template<class FORWARD_ITR_NEEDLE , class EQUAL >
EQUAL bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::equal ( ) const
inline

Return the functor used by this searcher object to compare value_type values.

◆ needleFirst()

template<class FORWARD_ITR_NEEDLE , class EQUAL >
FORWARD_ITR_NEEDLE bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::needleFirst ( ) const
inline

Return an iterator referring to the first element of the sequence of value_type values that can be sought by this searcher object.

◆ needleLast()

template<class FORWARD_ITR_NEEDLE , class EQUAL >
FORWARD_ITR_NEEDLE bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::needleLast ( ) const
inline

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.

◆ operator()()

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(needleFirst(), needleLast())
* bsl::distance(haystackFirst, haystackLast);
FORWARD_ITR_NEEDLE needleFirst() const
Definition bslstl_defaultsearcher.h:733
FORWARD_ITR_NEEDLE needleLast() const
Definition bslstl_defaultsearcher.h:741

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.

◆ operator=() [1/2]

template<class FORWARD_ITR_NEEDLE , class EQUAL = bsl::equal_to< typename bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>>
DefaultSearcher & bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::operator= ( const DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > &  rhs)
default

Assign to this object the state of the specified rhs object, and return a non-const reference to this object.

◆ operator=() [2/2]

template<class FORWARD_ITR_NEEDLE , class EQUAL = bsl::equal_to< typename bsl::iterator_traits<FORWARD_ITR_NEEDLE>::value_type>>
DefaultSearcher & bslstl::DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL >::operator= ( DefaultSearcher< FORWARD_ITR_NEEDLE, EQUAL > &&  rhs)
default

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.


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