From Jason Turner

[alg.adjacent.find]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjqlgiqkk/{from.md → to.md} +33 -11
tmp/tmpjqlgiqkk/{from.md → to.md} RENAMED
@@ -1,29 +1,51 @@
1
  ### Adjacent find <a id="alg.adjacent.find">[[alg.adjacent.find]]</a>
2
 
3
  ``` cpp
4
  template<class ForwardIterator>
5
- ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last);
 
6
  template<class ExecutionPolicy, class ForwardIterator>
7
- ForwardIterator adjacent_find(ExecutionPolicy&& exec,
 
8
  ForwardIterator first, ForwardIterator last);
9
 
10
  template<class ForwardIterator, class BinaryPredicate>
11
- ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last,
 
12
  BinaryPredicate pred);
13
  template<class ExecutionPolicy, class ForwardIterator, class BinaryPredicate>
14
- ForwardIterator adjacent_find(ExecutionPolicy&& exec,
 
15
  ForwardIterator first, ForwardIterator last,
16
  BinaryPredicate pred);
 
 
 
 
 
 
 
 
 
17
  ```
18
 
 
 
 
 
 
 
 
 
19
  *Returns:* The first iterator `i` such that both `i` and `i + 1` are in
20
- the range \[`first`, `last`) for which the following corresponding
21
- conditions hold: `*i == *(i + 1), pred(*i, *(i + 1)) != false`. Returns
22
- `last` if no such iterator is found.
23
 
24
  *Complexity:* For the overloads with no `ExecutionPolicy`, exactly
25
- `min((i - first) + 1, (last - first) - 1)` applications of the
26
- corresponding predicate, where `i` is `adjacent_find`’s return value.
27
- For the overloads with an `ExecutionPolicy`, 𝑂(`last - first`)
28
- applications of the corresponding predicate.
 
 
29
 
 
1
  ### Adjacent find <a id="alg.adjacent.find">[[alg.adjacent.find]]</a>
2
 
3
  ``` cpp
4
  template<class ForwardIterator>
5
+ constexpr ForwardIterator
6
+ adjacent_find(ForwardIterator first, ForwardIterator last);
7
  template<class ExecutionPolicy, class ForwardIterator>
8
+ ForwardIterator
9
+ adjacent_find(ExecutionPolicy&& exec,
10
  ForwardIterator first, ForwardIterator last);
11
 
12
  template<class ForwardIterator, class BinaryPredicate>
13
+ constexpr ForwardIterator
14
+ adjacent_find(ForwardIterator first, ForwardIterator last,
15
  BinaryPredicate pred);
16
  template<class ExecutionPolicy, class ForwardIterator, class BinaryPredicate>
17
+ ForwardIterator
18
+ adjacent_find(ExecutionPolicy&& exec,
19
  ForwardIterator first, ForwardIterator last,
20
  BinaryPredicate pred);
21
+
22
+ template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
23
+ indirect_binary_predicate<projected<I, Proj>,
24
+ projected<I, Proj>> Pred = ranges::equal_to>
25
+ constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {});
26
+ template<forward_range R, class Proj = identity,
27
+ indirect_binary_predicate<projected<iterator_t<R>, Proj>,
28
+ projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
29
+ constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {});
30
  ```
31
 
32
+ Let E be:
33
+
34
+ - `*i == *(i + 1)` for the overloads with no parameter `pred`;
35
+ - `pred(*i, *(i + 1)) != false` for the overloads with a parameter
36
+ `pred` and no parameter `proj`;
37
+ - `bool(invoke(pred, invoke(proj, *i), invoke(proj, *(i + 1))))` for the
38
+ overloads with both parameters `pred` and `proj`.
39
+
40
  *Returns:* The first iterator `i` such that both `i` and `i + 1` are in
41
+ the range \[`first`, `last`) for which E holds. Returns `last` if no
42
+ such iterator is found.
 
43
 
44
  *Complexity:* For the overloads with no `ExecutionPolicy`, exactly
45
+ $$\min(\texttt{(i - first) + 1}, \ \texttt{(last - first) - 1})$$
46
+ applications of the corresponding predicate, where `i` is
47
+ `adjacent_find`’s return value. For the overloads with an
48
+ `ExecutionPolicy`, 𝑂(`last - first`) applications of the corresponding
49
+ predicate, and no more than twice as many applications of any
50
+ projection.
51