Skip to content

Commit f067274

Browse files
author
Colin Robertson
committed
Implement Searcher class docs
1 parent 2c75fc1 commit f067274

5 files changed

Lines changed: 270 additions & 61 deletions

File tree

‎docs/standard-library/algorithm-functions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7444,7 +7444,7 @@ A forward iterator addressing the position one past the final element in the ran
74447444
User-defined predicate function object that defines the condition to be satisfied if two elements are to be taken as equivalent. A binary predicate takes two arguments and returns **true** when satisfied and **false** when not satisfied.
74457445

74467446
*searcher*\
7447-
The searcher that encapsulates the pattern to look for and the search algorithm to use.
7447+
The searcher that encapsulates the pattern to look for and the search algorithm to use. For more information on searchers, see [default_searcher class](default-searcher-class.md), [boyer_moore_horspool_searcher class](boyer-moore-horspool-searcher.md), and [boyer_moore_searcher class](boyer-moore-searcher.md).
74487448

74497449
### Return value
74507450

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,104 @@
11
---
2-
title: "boyer_moore_horspool_searcher Class"
3-
ms.date: "11/04/2016"
2+
title: "boyer_moore_horspool_searcher class"
3+
ms.date: "08/03/2019"
44
f1_keywords: ["functional/std::boyer_moore_horspool_searcher"]
55
helpviewer_keywords: ["std::boyer_moore_horspool_searcher [C++]"]
66
---
7-
# boyer_moore_horspool_searcher Class
7+
# boyer_moore_horspool_searcher class
8+
9+
The `boyer_moore_horspool_searcher` class is a function object type that uses the Boyer-Moore-Horspool algorithm to search for a sequence specified in the object's constructor. The search is done within another sequence provided to the object’s function call operator. This class is passed as a parameter to one of the overloads of [std::search](algorithm-functions.md#search).
810

911
## Syntax
1012

1113
```cpp
12-
template <class RandomAccessIterator1,
13-
class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>,
14-
class BinaryPredicate = equal_to<>>
15-
class boyer_moore_horspool_searcher {
16-
boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
17-
RandomAccessIterator1 pat_last,
18-
Hash hf = Hash(),
19-
BinaryPredicate pred = BinaryPredicate());
20-
template <class RandomAccessIterator2>
21-
pair<RandomAccessIterator2, RandomAccessIterator2>
22-
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
14+
template <
15+
class RandomAccessIterator,
16+
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
17+
class BinaryPredicate = equal_to<>>
18+
class boyer_moore_horspool_searcher
19+
{
20+
boyer_moore_horspool_searcher(
21+
RandomAccessIterator pat_first,
22+
RandomAccessIterator pat_last,
23+
Hash hf = Hash(),
24+
BinaryPredicate pred = BinaryPredicate());
25+
26+
template <class RandomAccessIterator2>
27+
pair<RandomAccessIterator2, RandomAccessIterator2> operator()(
28+
RandomAccessIterator2 first,
29+
RandomAccessIterator2 last) const;
2330
};
2431
```
2532
2633
## Members
2734
28-
### Constructors
35+
| | |
36+
| - | - |
37+
| **Constructor** | |
38+
| [boyer_moore_horspool_searcher](#boyer-moore-horspool-searcher-constructor) | |
39+
| **Operators** | |
40+
| [operator()](#operator-call) | |
41+
42+
## <a name="boyer-moore-horspool-searcher-constructor"></a>boyer_moore_horspool_searcher constructor
43+
44+
Constructs a `boyer_moore_horspool_searcher` function object by using the sequence to search for, a hash function object, and an equality predicate.
45+
46+
```cpp
47+
boyer_moore_horspool_searcher(
48+
RandomAccessIterator pat_first,
49+
RandomAccessIterator pat_last,
50+
Hash hf = Hash(),
51+
BinaryPredicate pred = BinaryPredicate());
52+
```
53+
54+
### Parameters
55+
56+
*pat_first*\
57+
The initial element of the sequence to search for.
58+
59+
*pat_last*\
60+
The end of the sequence to search for.
61+
62+
*hf*\
63+
A callable object, used to hash the sequence elements.
64+
65+
*pred*\
66+
The optional equality comparison predicate for sequence elements. If an equality comparison type isn't specified, the default is `std::equal_to`.
67+
68+
### Remarks
69+
70+
Throws any exception thrown by the copy constructor of the *BinaryPredicate*, *Hash*, or *RandomAccessIterator* types, or the call operator of *BinaryPredicate* or *Hash*.
71+
72+
This class is new in C++17.
73+
74+
## <a name="operator-call"></a> operator()
75+
76+
The call operator of the function operator. Searches within the argument sequence `[first, last)` for the sequence specified to the constructor.
77+
78+
```cpp
79+
template <class ForwardIterator2> // C++17
80+
pair<RandomAccessIterator2, RandomAccessIterator2> operator()(
81+
RandomAccessIterator2 first,
82+
RandomAccessIterator2 last) const;
83+
```
84+
85+
### Parameters
86+
87+
*first*\
88+
The initial element of the sequence to search within.
89+
90+
*last*\
91+
The end of the sequence to search within.
92+
93+
### Remarks
94+
95+
If the search pattern `[pat_first, pat_last)` is empty, returns `make_pair(first, first)`. If the search pattern isn't found, returns `make_pair(last, last)`. Otherwise, returns a pair of iterators to the beginning and end of a sequence in `[first, last)` that's equal to `[pat_first, pat_last)` according to the predicate *pred*.
2996
30-
|||
31-
|-|-|
32-
|[boyer_moore_horspool_searcher]()||
97+
This class is new in C++17.
3398
34-
### Operators
99+
## See also
35100
36-
|||
37-
|-|-|
38-
|[operator()]()||
101+
[\<functional>](functional.md)\
102+
[algorithm functions](algorithm-functions.md)\
103+
[boyer_moore_searcher class](boyer-moore-searcher.md)\
104+
[std::search](algorithm-functions.md#search)
Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,104 @@
11
---
2-
title: "boyer_moore_searcher Class"
3-
ms.date: "11/04/2016"
2+
title: "boyer_moore_searcher class"
3+
ms.date: "08/03/2019"
44
f1_keywords: ["functional/std::boyer_moore_searcher"]
55
helpviewer_keywords: ["std::boyer_moore_searcher [C++]"]
66
---
7-
# boyer_moore_searcher Class
7+
# boyer_moore_searcher class
8+
9+
The `boyer_moore_searcher` class is a function object type that uses the Boyer-Moore algorithm to search for a sequence specified in the object's constructor. The search is done within another sequence provided to the object’s function call operator. This class is passed as a parameter to one of the overloads of [std::search](algorithm-functions.md#search).
810

911
## Syntax
1012

1113
```cpp
12-
template <class RandomAccessIterator1,
14+
template <
15+
class RandomAccessIterator1,
1316
class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>,
14-
class BinaryPredicate = equal_to<>>
15-
class boyer_moore_searcher {
16-
boyer_moore_searcher(RandomAccessIterator1 pat_first,
17-
RandomAccessIterator1 pat_last,
18-
Hash hf = Hash(),
19-
BinaryPredicate pred = BinaryPredicate());
20-
template <class RandomAccessIterator2>
21-
pair<RandomAccessIterator2, RandomAccessIterator2>
22-
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
17+
class BinaryPredicate = equal_to<>>
18+
class boyer_moore_searcher
19+
{
20+
boyer_moore_searcher(
21+
RandomAccessIterator1 pat_first,
22+
RandomAccessIterator1 pat_last,
23+
Hash hf = Hash(),
24+
BinaryPredicate pred = BinaryPredicate());
25+
26+
template <class RandomAccessIterator2>
27+
pair<RandomAccessIterator2, RandomAccessIterator2> operator()(
28+
RandomAccessIterator2 first,
29+
RandomAccessIterator2 last) const;
2330
};
2431
```
2532
2633
## Members
2734
28-
### Constructors
35+
| | |
36+
| - | - |
37+
| **Constructor** | |
38+
|[boyer_moore_searcher](#boyer-moore-searcher-constructor)||
39+
| **Operators** | |
40+
| [operator()](#operator-call) | |
41+
42+
## <a name="boyer-moore-searcher-constructor"></a>boyer_moore_searcher constructor
43+
44+
Constructs a `boyer_moore_searcher` function object by using the sequence to search for, a hash function object, and an equality predicate.
45+
46+
```cpp
47+
boyer_moore_searcher(
48+
RandomAccessIterator pat_first,
49+
RandomAccessIterator pat_last,
50+
Hash hf = Hash(),
51+
BinaryPredicate pred = BinaryPredicate());
52+
```
53+
54+
### Parameters
55+
56+
*pat_first*\
57+
The initial element of the sequence to search for.
58+
59+
*pat_last*\
60+
The end of the sequence to search for.
61+
62+
*hf*\
63+
A callable object, used to hash the sequence elements.
64+
65+
*pred*\
66+
The optional equality comparison predicate for sequence elements. If an equality comparison type isn't specified, the default is `std::equal_to`.
67+
68+
### Remarks
69+
70+
Throws any exception thrown by the copy constructor of the *BinaryPredicate*, *Hash*, or *RandomAccessIterator* types, or the call operator of *BinaryPredicate* or *Hash*.
71+
72+
This class is new in C++17.
73+
74+
## <a name="operator-call"></a> operator()
75+
76+
The call operator of the function operator. Searches within the argument sequence `[first, last)` for the sequence specified to the constructor.
77+
78+
```cpp
79+
template <class ForwardIterator2>
80+
pair<RandomAccessIterator2, RandomAccessIterator2> operator()(
81+
RandomAccessIterator2 first,
82+
RandomAccessIterator2 last) const;
83+
```
84+
85+
### Parameters
86+
87+
*first*\
88+
The initial element of the sequence to search within.
89+
90+
*last*\
91+
The end of the sequence to search within.
92+
93+
### Remarks
94+
95+
If the search pattern `[pat_first, pat_last)` is empty, returns `make_pair(first, first)`. If the search pattern isn't found, returns `make_pair(last, last)`. Otherwise, returns a pair of iterators to the beginning and end of a sequence in `[first, last)` that's equal to `[pat_first, pat_last)` according to the predicate *pred*.
2996
30-
|||
31-
|-|-|
32-
|[boyer_moore_searcher]()||
97+
This class is new in C++17.
3398
34-
### Operators
99+
## See also
35100
36-
|||
37-
|-|-|
38-
|[operator()]()||
101+
[\<functional>](functional.md)\
102+
[algorithm functions](algorithm-functions.md)\
103+
[boyer_moore_horspool_searcher class](boyer-moore-horspool-searcher.md)\
104+
[std::search](algorithm-functions.md#search)
Lines changed: 92 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,111 @@
11
---
2-
title: "default_searcher Class"
3-
ms.date: "11/04/2016"
2+
title: "default_searcher class"
3+
ms.date: "08/03/2019"
44
f1_keywords: ["functional/std::default_searcher"]
55
helpviewer_keywords: ["std::default_searcher [C++]"]
66
---
77
# default_searcher Class
88

9+
A `default_searcher` is a function object type for operations that search for a sequence specified in the object's constructor. The search is done within another sequence provided to the object’s function call operator. The `default_searcher` invokes [std::search](algorithm-functions.md#search) to perform the search.
10+
911
## Syntax
1012

1113
```cpp
12-
template <class ForwardIterator1, class BinaryPredicate = equal_to<>>
13-
class default_searcher {
14-
default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last,
14+
template <class ForwardIterator, class BinaryPredicate = equal_to<>>
15+
class default_searcher
16+
{
17+
default_searcher(
18+
ForwardIterator pat_first,
19+
ForwardIterator pat_last,
1520
BinaryPredicate pred = BinaryPredicate());
21+
1622
template <class ForwardIterator2>
17-
pair<ForwardIterator2, ForwardIterator2>
18-
operator()(ForwardIterator2 first, ForwardIterator2 last) const;
23+
pair<ForwardIterator2, ForwardIterator2> operator()(
24+
ForwardIterator2 first,
25+
ForwardIterator2 last) const;
1926
};
2027
```
2128
2229
## Members
2330
24-
### Constructors
31+
| | |
32+
| - | - |
33+
| **Constructor** | |
34+
| [default_searcher](#default-searcher-constructor) | |
35+
| **Operators** | |
36+
| [operator()](#operator-call) | |
37+
38+
## <a name="default-searcher-constructor"></a>default_searcher constructor
39+
40+
Constructs a `default_searcher` function object by using the sequence to search for and an equality predicate.
41+
42+
```cpp
43+
default_searcher( // C++17
44+
ForwardIterator pat_first,
45+
ForwardIterator pat_last,
46+
BinaryPredicate pred = BinaryPredicate());
47+
48+
constexpr default_searcher( // C++20
49+
ForwardIterator pat_first,
50+
ForwardIterator pat_last,
51+
BinaryPredicate pred = BinaryPredicate());
52+
```
53+
54+
### Parameters
55+
56+
*pat_first*\
57+
The initial element of the sequence to search for.
58+
59+
*pat_last*\
60+
The end of the sequence to search for.
61+
62+
*pred*\
63+
The optional equality comparison predicate for sequence elements. If an equality comparison type isn't specified, the default is `std::equal_to`.
64+
65+
### Remarks
66+
67+
Throws any exception thrown by the copy constructor of the *BinaryPredicate* or *ForwardIterator* types.
68+
69+
This class is new in C++17. C++20 made the constructor `constexpr`.
70+
71+
## <a name="operator-call"></a> operator()
72+
73+
The call operator of the function operator. Searches within the argument sequence `[first, last)` for the sequence specified to the constructor.
74+
75+
```cpp
76+
template <class ForwardIterator2> // C++17
77+
pair<ForwardIterator2, ForwardIterator2> operator()(
78+
ForwardIterator2 first,
79+
ForwardIterator2 last) const;
80+
81+
template <class ForwardIterator2> // C++20
82+
constexpr pair<ForwardIterator2, ForwardIterator2> operator()(
83+
ForwardIterator2 first,
84+
ForwardIterator2 last) const;
85+
```
86+
87+
### Parameters
88+
89+
*first*\
90+
The initial element of the sequence to search within.
91+
92+
*last*\
93+
The end of the sequence to search within.
94+
95+
### Remarks
96+
97+
Returns a pair of iterators. The initial iterator *i* is the effective result of:
98+
99+
`std::search( first, last, pat_first, pat_last, pred )`.
100+
101+
The second iterator of the pair is *last* if *i** is *last*. Otherwise, it's the effective result of:
102+
103+
`std::next( i, std::distance( pat_first, pat_last ))`.
25104
26-
|||
27-
|-|-|
28-
|[default_searcher]()||
105+
This class is new in C++17. C++20 made the call operator `constexpr`.
29106
30-
### Operators
107+
## See also
31108
32-
|||
33-
|-|-|
34-
|[operator()]()||
109+
[\<functional>](functional.md)\
110+
[algorithm functions](algorithm-functions.md)\
111+
[std::search](algorithm-functions.md#search)

0 commit comments

Comments
 (0)