@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
11
11
12
12
The header file 'find_backward.hpp' contains variants of the stl algorithm
13
13
`find`. These variants are like `find`, except that the evaluate the elements
14
- of the given sequence if reverse order.
14
+ of the given sequence in reverse order.
15
15
16
16
Consider how finding the last element that is equal to `x` in a range is
17
17
typically done:
@@ -23,57 +23,58 @@ typically done:
23
23
}
24
24
}
25
25
26
- Raw loops are icky though. PErhaps we should do a bit of extra work to allow
26
+ Raw loops are icky though. Perhaps we should do a bit of extra work to allow
27
27
the use of `std::find()`:
28
28
29
29
auto rfirst = std::make_reverse_iterator(last);
30
30
auto rlast = std::make_reverse_iterator(first);
31
31
auto it = std::find(rfirst, rlast);
32
32
// Use it here...
33
33
34
- That seems nicer, but it has two major drawbacks. First, it requires an
35
- unpleasant amount of typing. Second, it is considerably less efficient than
36
- forward-iterator `find` , since `std::reverse_iterator` calls its
37
- base-iterator's `operator--()` in most of its members before doing the work
38
- that the member requires.
34
+ That seems nicer in that there is no raw loop , but it has two major drawbacks.
35
+ First, it requires an unpleasant amount of typing. Second, it is less
36
+ efficient than forward-iterator `find` , since `std::reverse_iterator` calls
37
+ its base-iterator's `operator--()` in most of its member functions before
38
+ doing the work that the member function requires.
39
39
40
40
[heading interface]
41
41
42
42
template<typename BidiIter, typename T>
43
- BidiIter find_backward(BidiIter first, BidiIter last, T const & x);
43
+ BidiIter find_backward(BidiIter first, BidiIter last, const T & x);
44
44
45
45
template<typename Range, typename T>
46
- boost::range_iterator<Range> find_backward(Range & range, T const & x);
46
+ boost::range_iterator<Range> find_backward(Range & range, const T & x);
47
47
48
- The function `find_backward` returns an iterator to the last element that is
49
- equal to `x` in `[first, last)` or `r`, respectively.
48
+ These overloads of `find_backward` return an iterator to the last element that
49
+ is equal to `x` in `[first, last)` or `r`, respectively.
50
50
51
51
template<typename BidiIter, typename T>
52
- BidiIter find_not_backward(BidiIter first, BidiIter last, T const & x);
52
+ BidiIter find_not_backward(BidiIter first, BidiIter last, const T & x);
53
53
54
54
template<typename Range, typename T>
55
- boost::range_iterator<Range> find_not_backward(Range & range, T const & x);
55
+ boost::range_iterator<Range> find_not_backward(Range & range, const T & x);
56
56
57
- The function `find_not_backward` returns an iterator to the last element that
58
- is not equal to `x` in `[first, last)` or `r`, respectively.
57
+ These overloads of `find_not_backward` return an iterator to the last element
58
+ that is not equal to `x` in `[first, last)` or `r`, respectively.
59
59
60
60
template<typename BidiIter, typename Pred>
61
61
BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p);
62
62
63
63
template<typename Range, typename Pred>
64
64
boost::range_iterator<Range> find_if_backward(Range & range, Pred p);
65
65
66
- The function `find_if_backward` returns an iterator to the last element for
67
- which `pred` returns `true` in `[first, last)` or `r`, respectively.
66
+ These overloads of `find_if_backward` return an iterator to the last element
67
+ for which `pred` returns `true` in `[first, last)` or `r`, respectively.
68
68
69
69
template<typename BidiIter, typename Pred>
70
70
BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p);
71
71
72
72
template<typename Range, typename Pred>
73
73
boost::range_iterator<Range> find_if_not_backward(Range & range, Pred p);
74
74
75
- The function `find_if_not_backward` returns an iterator to the last element
76
- for which `pred` returns `false` in `[first, last)` or `r`, respectively.
75
+ These overloads of `find_if_not_backward` return an iterator to the last
76
+ element for which `pred` returns `false` in `[first, last)` or `r`,
77
+ respectively.
77
78
78
79
[heading Examples]
79
80
0 commit comments