boyer_moore_horspool_searcher 类

boyer_moore_horspool_searcher 类是一种函数对象类型,它使用 Boyer-Moore-Horspool 算法搜索对象构造函数中指定的序列。 搜索在提供给对象的函数调用运算符的另一个序列内完成。 此类作为参数传递给 std::search 的重载之一。

语法

template <
    class RandomAccessIterator,
    class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
    class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher
{
    boyer_moore_horspool_searcher(
        RandomAccessIterator pat_first,
        RandomAccessIterator pat_last,
        Hash hf = Hash(),
        BinaryPredicate pred = BinaryPredicate());

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

成员

成员 说明
构造函数
boyer_moore_horspool_searcher 构造搜索器实例。
运算符
operator() 在序列上调用操作。

boyer_moore_horspool_searcher 构造函数

通过使用要搜索的序列、哈希函数对象和相等谓词来构造 boyer_moore_horspool_searcher 函数对象。

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

参数

pat_first
要搜索的序列的初始元素。

pat_last
要搜索的序列的结尾。

hf
一个可调用对象,用于对序列元素进行哈希处理。

pred
序列元素的可选相等比较谓词。 如果未指定相等比较类型,则默认为 std::equal_to

注解

引发由 BinaryPredicate、Hash 或 RandomAccessIterator 类型的复制构造函数或 BinaryPredicate 或 Hash 的调用运算符引发的任何异常

此类是 C++17 中的新增类。

operator()

函数对象的调用运算符。 在参数序列 [first, last) 中搜索指定给构造函数的序列。

template <class ForwardIterator2>   // C++17
pair<RandomAccessIterator2, RandomAccessIterator2> operator()(
    RandomAccessIterator2 first,
    RandomAccessIterator2 last) const;

参数

first
要在其中搜索的序列的初始元素。

last
要在其中搜索的序列的结尾。

备注

如果搜索模式 [pat_first, pat_last) 为空,则返回 make_pair(first, first)。 如果未找到搜索模式,则返回 make_pair(last, last)。 否则,将一对迭代器返回到根据谓词 pred 等于 [pat_first, pat_last)[first, last) 中序列的开头和结尾

此类是 C++17 中的新增类。

另请参阅

<functional>
algorithm 函数
boyer_moore_searcher 类
std::search