std::experimental:: boyer_moore_horspool_searcher, std::experimental:: make_boyer_moore_horspool_searcher
|
ヘッダーで定義
<experimental/functional>
|
||
|
template
<
class
RandomIt1,
class
Hash
=
std::
hash
<
typename
std::
iterator_traits
<
RandomIt1
>
::
value_type
>
,
|
(ライブラリ基盤仕様 TS) | |
std::experimental::search での使用に適したサーチャで、 Boyer-Moore-Horspool文字列検索アルゴリズム を実装しています。
boyer_moore_horspool_searcher
は
CopyConstructible
および
CopyAssignable
の要件を満たします。
RandomIt1
は
LegacyRandomAccessIterator
の要件を満たさなければなりません。
目次
メンバー関数std::experimental::boyer_moore_horspool_searcher::boyer_moore_horspool_searcher
を構築します。このとき、
任意の2つの値 パラメータ
例外投げられる例外は、以下のいずれかによる:
また、内部データ構造に必要な追加メモリを割り当てられない場合は、std::bad_alloc を投げる可能性がある. std::experimental::boyer_moore_horspool_searcher::operator()
このメンバ関数は、std::experimental::searchによってこのサーチャーで検索を実行するために呼び出されます。
パラメータ
戻り値
ヘルパー関数
テンプレート実引数推定を使用して パラメータ
戻り値
例
このコードを実行
#include <experimental/algorithm> #include <experimental/functional> #include <iostream> #include <string> int main() { std::string in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit," " sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"; std::string needle = "pisci"; auto it = std::experimental::search(in.begin(), in.end(), std::experimental::make_boyer_moore_horspool_searcher( needle.begin(), needle.end())); if (it != in.end()) std::cout << "The string " << needle << " found at offset " << it - in.begin() << '\n'; else std::cout << "The string " << needle << " not found\n"; } 出力: The string pisci found at offset 43 関連項目
|