Updated:

less than 1 minute read

개요

  • search
  • default_searcher
    • 표준 C++ 라이브러리 검색 알고리즘
  • boyer_moore_searcher
    • Boyer-Moore 검색 알고리즘
  • boyer_moore_horspool_searcher
    • Boyer-Moore-Horspool 검색 알고리즘


예제

  • 코드
     #include <algorithm>
     #include <functional>
     #include <iostream>
     #include <vector>
        
     using namespace std;
        
     int main() {
     	vector<int> v1{1, 2, 3, 4, 5};
     	vector<int> v2{3, 4, 5};
        
     	auto it1 = search(v1.begin(), v1.end(), v2.begin(), v2.end());
     	cout << *it1 << endl;
        
     	auto it2 =
     		search(v1.begin(), v1.end(), default_searcher(v2.begin(), v2.end()));
     	cout << *it2 << endl;
        
     	auto it3 = search(v1.begin(), v1.end(),
     					  boyer_moore_searcher(v2.begin(), v2.end()));
     	cout << *it3 << endl;
        
     	auto it4 = search(v1.begin(), v1.end(),
     					  boyer_moore_horspool_searcher(v2.begin(), v2.end()));
     	cout << *it4 << endl;
        
     	return 0;
     }
    
  • 실행 결과
     3
     3
     3
     3