New Algorithms Available in C++ 17
The lesson provides a brief overview of how C++17 has updated std::search and provided new searcher algorithms.
C++17
updated std::search
algorithm in two ways:
- You can now use execution policy to run the default version of the algorithm in a parallel way.
- You can provide a Searcher object that handles the search.
In C++17
we have three searchers:
default_searcher
- same as the version before C++17, usually meaning the naive approach. Operates on Forward Iterators.boyer_moore_searcher
- uses Boyer Moore Algorithm - the full version, with two rules: bad character rule and good suffix rule. Operates on Random Access Iterators.boyer_moore_horspool_searcher
- Simplified version of Boyer-Moore that uses only Bad Character Rule, but still has good average complexity. Operates on Random Access Iterators.
std::search
with a searcher cannot be used along with execution policy.
So, folks! it’s time to use the searchers.
Get hands-on with 1400+ tech skills courses.