std::experimental::search
From cppreference.com
< cpp | experimental
| ヘッダ <experimental/algorithm> で定義 |
||
| template< class ForwardIterator, class Searcher > ForwardIterator search( ForwardIterator first, ForwardIterator last, |
(Library Fundamentals TS) | |
シーケンス [first, last) の中で、searcher のコンストラクタで指定されたパターンを検索します。
|
searcher(first, last) を効果的に実行します。 |
(C++17まで) |
|
searcher(first, last).first を効果的に実行します。 |
(C++17以降) |
Searcher は CopyConstructible である必要はありません。
標準ライブラリは以下のサーチを提供します。
| 標準C++ライブラリの探索アルゴリズム実装 (クラステンプレート) | |
| ボイヤー・ムーア法探索アルゴリズム実装 (クラステンプレート) | |
| ボイヤー・ムーア・ホースプール法探索アルゴリズム実装 (クラステンプレート) |
目次 |
[編集] パラメータ
| |||
[編集] 返り値
searcher.operator() の結果を返します。これは、部分文字列が見つかった場所へのイテレータ、または見つからなかった場合は last のコピーです。
[編集] 計算量
サーチによって異なります。
[編集] 例
このコードを実行
#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_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
[編集] 関連項目
| 要素の範囲の最初の出現を検索する (関数テンプレート) |