find_{not,*backward} docs copy editing.

This commit is contained in:
Zach Laine
2018-05-12 16:47:47 -05:00
parent c5c5d24ff3
commit 6b2246468e
2 changed files with 27 additions and 28 deletions

View File

@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
The header file 'find_backward.hpp' contains variants of the stl algorithm
`find`. These variants are like `find`, except that the evaluate the elements
of the given sequence if reverse order.
of the given sequence in reverse order.
Consider how finding the last element that is equal to `x` in a range is
typically done:
@ -23,7 +23,7 @@ typically done:
}
}
Raw loops are icky though. PErhaps we should do a bit of extra work to allow
Raw loops are icky though. Perhaps we should do a bit of extra work to allow
the use of `std::find()`:
auto rfirst = std::make_reverse_iterator(last);
@ -31,31 +31,31 @@ the use of `std::find()`:
auto it = std::find(rfirst, rlast);
// Use it here...
That seems nicer, but it has two major drawbacks. First, it requires an
unpleasant amount of typing. Second, it is considerably less efficient than
forward-iterator `find` , since `std::reverse_iterator` calls its
base-iterator's `operator--()` in most of its members before doing the work
that the member requires.
That seems nicer in that there is no raw loop, but it has two major drawbacks.
First, it requires an unpleasant amount of typing. Second, it is less
efficient than forward-iterator `find` , since `std::reverse_iterator` calls
its base-iterator's `operator--()` in most of its member functions before
doing the work that the member function requires.
[heading interface]
template<typename BidiIter, typename T>
BidiIter find_backward(BidiIter first, BidiIter last, T const & x);
BidiIter find_backward(BidiIter first, BidiIter last, const T & x);
template<typename Range, typename T>
boost::range_iterator<Range> find_backward(Range & range, T const & x);
boost::range_iterator<Range> find_backward(Range & range, const T & x);
The function `find_backward` returns an iterator to the last element that is
equal to `x` in `[first, last)` or `r`, respectively.
These overloads of `find_backward` return an iterator to the last element that
is equal to `x` in `[first, last)` or `r`, respectively.
template<typename BidiIter, typename T>
BidiIter find_not_backward(BidiIter first, BidiIter last, T const & x);
BidiIter find_not_backward(BidiIter first, BidiIter last, const T & x);
template<typename Range, typename T>
boost::range_iterator<Range> find_not_backward(Range & range, T const & x);
boost::range_iterator<Range> find_not_backward(Range & range, const T & x);
The function `find_not_backward` returns an iterator to the last element that
is not equal to `x` in `[first, last)` or `r`, respectively.
These overloads of `find_not_backward` return an iterator to the last element
that is not equal to `x` in `[first, last)` or `r`, respectively.
template<typename BidiIter, typename Pred>
BidiIter find_if_backward(BidiIter first, BidiIter last, Pred p);
@ -63,8 +63,8 @@ is not equal to `x` in `[first, last)` or `r`, respectively.
template<typename Range, typename Pred>
boost::range_iterator<Range> find_if_backward(Range & range, Pred p);
The function `find_if_backward` returns an iterator to the last element for
which `pred` returns `true` in `[first, last)` or `r`, respectively.
These overloads of `find_if_backward` return an iterator to the last element
for which `pred` returns `true` in `[first, last)` or `r`, respectively.
template<typename BidiIter, typename Pred>
BidiIter find_if_not_backward(BidiIter first, BidiIter last, Pred p);
@ -72,8 +72,9 @@ which `pred` returns `true` in `[first, last)` or `r`, respectively.
template<typename Range, typename Pred>
boost::range_iterator<Range> find_if_not_backward(Range & range, Pred p);
The function `find_if_not_backward` returns an iterator to the last element
for which `pred` returns `false` in `[first, last)` or `r`, respectively.
These overloads of `find_if_not_backward` return an iterator to the last
element for which `pred` returns `false` in `[first, last)` or `r`,
respectively.
[heading Examples]

View File

@ -23,9 +23,7 @@ the first occurrance of any number besides `1` in `vec`? We have to write an
unfortunate amount of code:
auto std::vector<int> vec = { 1, 1, 2 };
auto it = std::find_if(
vec.begin(), vec.end(),
[](int i) { return i != 1; });
auto it = std::find_if(vec.begin(), vec.end(), [](int i) { return i != 1; });
With `find_not()` the code gets much more terse:
@ -35,18 +33,18 @@ With `find_not()` the code gets much more terse:
The existing `find` variants are: `find()`, `find_if()`, and `find_if_not()`.
It seems natural to also have `find_not()`, for the very reason that we have
`find_if_not()` -- to avoid having to write a lambda to wrap the negation of
our find condition.
the find condition.
[heading interface]
template<typename InputIter, typename Sentinel, typename T>
InputIter find_not(InputIter first, Sentinel last, T const & x);
InputIter find_not(InputIter first, Sentinel last, const T & x);
template<typename Range, typename T>
boost::range_iterator<Range> find_not(Range & r, T const & x);
boost::range_iterator<Range> find_not(Range & r, const T & x);
The function `find_not` returns the first value that is not equal to `x` in
the sequence `[first, last)` or `r`, respectively.
These overloads of `find_not` return the first value that is not equal to `x`
in the sequence `[first, last)` or `r`, respectively.
[heading Examples]
@ -57,7 +55,7 @@ Given the container `c1` containing `{ 0, 1, 2 }`, then
[heading Iterator Requirements]
`equal` works on all iterators except output iterators.
`find_not` works on all iterators except output iterators.
The template parameter `Sentinel` is allowed to be different from `InputIter`,
or they may be the same. For an `InputIter` `it` and a `Sentinel` `end`, `it