From Jason Turner

[alg.nth.element]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp87vw8l1v/{from.md → to.md} +19 -9
tmp/tmp87vw8l1v/{from.md → to.md} RENAMED
@@ -2,25 +2,35 @@
2
 
3
  ``` cpp
4
  template<class RandomAccessIterator>
5
  void nth_element(RandomAccessIterator first, RandomAccessIterator nth,
6
  RandomAccessIterator last);
 
 
 
 
7
 
8
  template<class RandomAccessIterator, class Compare>
9
  void nth_element(RandomAccessIterator first, RandomAccessIterator nth,
10
  RandomAccessIterator last, Compare comp);
 
 
 
 
11
  ```
12
 
13
- After `nth_element` the element in the position pointed to by `nth` is
14
- the element that would be in that position if the whole range were
15
- sorted, unless `nth == last`. Also for every iterator `i` in the range
16
- \[`first`, `nth`) and every iterator `j` in the range \[`nth`, `last`)
17
- it holds that: `!(*j < *i)` or `comp(*j, *i) == false`.
18
-
19
  *Requires:* `RandomAccessIterator` shall satisfy the requirements of
20
  `ValueSwappable` ([[swappable.requirements]]). The type of `*first`
21
  shall satisfy the requirements of `MoveConstructible`
22
- (Table  [[moveconstructible]]) and of `MoveAssignable`
23
- (Table  [[moveassignable]]).
24
 
25
- *Complexity:* Linear on average.
 
 
 
 
 
 
 
 
26
 
 
2
 
3
  ``` cpp
4
  template<class RandomAccessIterator>
5
  void nth_element(RandomAccessIterator first, RandomAccessIterator nth,
6
  RandomAccessIterator last);
7
+ template<class ExecutionPolicy, class RandomAccessIterator>
8
+ void nth_element(ExecutionPolicy&& exec,
9
+ RandomAccessIterator first, RandomAccessIterator nth,
10
+ RandomAccessIterator last);
11
 
12
  template<class RandomAccessIterator, class Compare>
13
  void nth_element(RandomAccessIterator first, RandomAccessIterator nth,
14
  RandomAccessIterator last, Compare comp);
15
+ template<class ExecutionPolicy, class RandomAccessIterator, class Compare>
16
+ void nth_element(ExecutionPolicy&& exec,
17
+ RandomAccessIterator first, RandomAccessIterator nth,
18
+ RandomAccessIterator last, Compare comp);
19
  ```
20
 
 
 
 
 
 
 
21
  *Requires:* `RandomAccessIterator` shall satisfy the requirements of
22
  `ValueSwappable` ([[swappable.requirements]]). The type of `*first`
23
  shall satisfy the requirements of `MoveConstructible`
24
+ (Table  [[tab:moveconstructible]]) and of `MoveAssignable`
25
+ (Table  [[tab:moveassignable]]).
26
 
27
+ *Effects:* After `nth_element` the element in the position pointed to by
28
+ `nth` is the element that would be in that position if the whole range
29
+ were sorted, unless `nth == last`. Also for every iterator `i` in the
30
+ range \[`first`, `nth`) and every iterator `j` in the range \[`nth`,
31
+ `last`) it holds that: `!(*j < *i)` or `comp(*j, *i) == false`.
32
+
33
+ *Complexity:* For the overloads with no `ExecutionPolicy`, linear on
34
+ average. For the overloads with an `ExecutionPolicy`, 𝑂(N) applications
35
+ of the predicate, and 𝑂(N log N) swaps, where N = `last - first`.
36