[func.search.bmh] (original) (raw)

20 General utilities library [utilities]

20.14 Function objects [function.objects]

20.14.18 Searchers [func.search]

20.14.18.4 Class template boyer_­moore_­horspool_­searcher [func.search.bmh]

template<class RandomAccessIterator1,class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>,class BinaryPredicate = equal_to<>> class boyer_moore_horspool_searcher { public: boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());template<class RandomAccessIterator2> pair<RandomAccessIterator2, RandomAccessIterator2> operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;private: RandomAccessIterator1 pat_first_; RandomAccessIterator1 pat_last_; Hash hash_; BinaryPredicate pred_; };

boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());

Preconditions: The value type of RandomAccessIterator1 meets the Cpp17DefaultConstructible,Cpp17CopyConstructible, and Cpp17CopyAssignable requirements.

Let V be iterator_­traits<RandomAccessIterator1>​::​value_­type.

For any two values A and B of type V, if pred(A, B) == true, then hf(A) == hf(B) is true.

Effects: Initializespat_­first_­ with pat_­first,pat_­last_­ with pat_­last,hash_­ with hf, andpred_­ with pred.

Throws: Any exception thrown by the copy constructor of RandomAccessIterator1, or by the default constructor, copy constructor, or the copy assignment operator of the value type of RandomAccessIterator1or the copy constructor or operator() of BinaryPredicate or Hash.

May throw bad_­alloc if additional memory needed for internal data structures cannot be allocated.

template<class RandomAccessIterator2> pair<RandomAccessIterator2, RandomAccessIterator2> operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;

Mandates: RandomAccessIterator1 and RandomAccessIterator2have the same value type.

Effects: Finds a subsequence of equal values in a sequence.

Returns: A pair of iterators i and j such that

Returns make_­pair(first, first) if [pat_­first_­, pat_­last_­) is empty, otherwise returns make_­pair(last, last) if no such iterator is found.

Complexity: At most (last - first) * (pat_­last_­ - pat_­first_­) applications of the predicate.