Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::boyer_...ol_searcher(3)  C++ Standard Libary std::boyer_...ol_searcher(3)

NAME
       std::boyer_moore_horspool_searcher - std::boyer_moore_horspool_searcher

Synopsis
	  Defined in header <functional>
	  template< class RandomIt1,

		    class Hash = std::hash<typename
	  std::iterator_traits<RandomIt1>::value_type>,
       (since C++17)
		    class BinaryPredicate = std::equal_to<> >

	  class	boyer_moore_horspool_searcher;

	  A   searcher	 suitable  for	use  with  the	Searcher  overload  of
       std::search that
	  implements the Boyer-Moore-Horspool string searching algorithm.

	  std::boyer_moore_horspool_searcher is	CopyConstructible and  CopyAs-
       signable.

	  RandomIt1 must meet the requirements of LegacyRandomAccessIterator.

Member functions
       std::boyer_moore_horspool_searcher::boyer_moore_horspool_searcher

	  boyer_moore_horspool_searcher( RandomIt1 pat_first,

					 RandomIt1 pat_last,
					 Hash hf = Hash(),

					 BinaryPredicate  pred	= BinaryPredi-
       cate() );

	  Constructs a std::boyer_moore_horspool_searcher by storing copies of
       pat_first,
	  pat_last, hf,	and pred,  setting  up	any  necessary	internal  data
       structures.

	  The  value  type of RandomIt1	must be	DefaultConstructible, CopyCon-
       structible and
	  CopyAssignable.

	  For any two values A and B  of  the  type  std::iterator_traits<Ran-
       domIt1>::value_type,
	  if pred(A, B)	== true, then hf(A) == hf(B) shall be true.

Parameters
	  pat_first,  pat_last - a pair	of iterators designating the string to
       be searched for
	  hf		      -	a callable object used to hash the elements of
       the string
	  pred		      -	a callable object used to determine equality

Exceptions
	  Any exceptions thrown	by

	    * the copy constructor of RandomIt1;
	    * the default constructor, copy constructor,  or  copy  assignment
       operator	of the
	      value type of RandomIt1; or
	    *  the  copy constructor or	function call operator of BinaryPredi-
       cate or Hash.

	  May also throw std::bad_alloc	if additional memory required for  in-
       ternal data
	  structures cannot be allocated.

       std::boyer_moore_horspool_searcher::operator()

	  template< class RandomIt2 >
	  std::pair<RandomIt2,	RandomIt2>  operator()(	 RandomIt2 first, Ran-
       domIt2 last )
	  const;

	  The member function called by	the Searcher overload  of  std::search
       to perform a
	  search with this searcher. RandomIt2 must meet the requirements of
	  LegacyRandomAccessIterator.

	  RandomIt1 and	RandomIt2 must have the	same value type.

Parameters
	  first, last -	a pair of iterators designating	the string to be exam-
       ined

Return value
	  If   the   pattern   [pat_first,   pat_last)	 is   empty,   returns
       std::make_pair(first, first).

	  Otherwise, returns a pair of iterators to the	 first	and  one  past
       last positions in
	  [first, last)	where a	subsequence that compares equal	to [pat_first,
       pat_last) as
	  defined by pred is located, or std::make_pair(last, last) otherwise.

Notes
		Feature-test macro	  Value	   Std	  Feature
	  __cpp_lib_boyer_moore_searcher 201603L (C++17) searchers

Example
       // Run this code

	#include <algorithm>
	#include <functional>
	#include <iomanip>
	#include <iostream>
	#include <string_view>

	int main()
	{
	    constexpr std::string_view in =
		"Lorem	ipsum dolor sit	amet, consectetur adipiscing elit, sed
       "
		"do eiusmod tempor incididunt ut labore	et dolore  magna  ali-
       qua";

	    const std::string_view needle{"pisci"};

	    auto it = std::search(in.begin(), in.end(),
			  std::boyer_moore_horspool_searcher(
			      needle.begin(), needle.end()));
	    if (it != in.end())
		std::cout  <<  "The string " <<	std::quoted(needle) << " found
       at offset "
			  << it	- in.begin() <<	'\n';
	    else
		std::cout << "The string " <<  std::quoted(needle)  <<	"  not
       found\n";
	}

Output:
	The string "pisci" found at offset 43

See also
	  search	       searches	for a range of elements
			       (function template)
	  default_searcher     standard	C++ library search algorithm implemen-
       tation
	  (C++17)	       (class template)
	  boyer_moore_searcher Boyer-Moore search algorithm implementation
	  (C++17)	       (class template)

http://cppreference.com		  2024.06.10	  std::boyer_...ol_searcher(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::boyer_moore_horspool_searcher&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help