tmp/tmp9jj9b0gq/{from.md → to.md}
RENAMED
|
@@ -42,14 +42,16 @@ template<class InputIterator, class OutputIterator, class Predicate>
|
|
| 42 |
`result + (last - first)`) shall not overlap.
|
| 43 |
|
| 44 |
*Effects:* Copies all of the elements referred to by the iterator `i` in
|
| 45 |
the range \[`first`, `last`) for which `pred(*i)` is `true`.
|
| 46 |
|
|
|
|
|
|
|
| 47 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 48 |
predicate.
|
| 49 |
|
| 50 |
-
*Remarks:* Stable.
|
| 51 |
|
| 52 |
``` cpp
|
| 53 |
template<class BidirectionalIterator1, class BidirectionalIterator2>
|
| 54 |
BidirectionalIterator2
|
| 55 |
copy_backward(BidirectionalIterator1 first,
|
|
@@ -297,19 +299,19 @@ requirements (Table [[moveassignable]]).
|
|
| 297 |
the range \[`first`, `last`) for which the following corresponding
|
| 298 |
conditions hold: `*i == value, pred(*i) != false`.
|
| 299 |
|
| 300 |
*Returns:* The end of the resulting range.
|
| 301 |
|
| 302 |
-
*Remarks:* Stable.
|
| 303 |
|
| 304 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 305 |
predicate.
|
| 306 |
|
| 307 |
*Note:* each element in the range \[`ret`, `last`), where `ret` is the
|
| 308 |
returned value, has a valid but unspecified state, because the
|
| 309 |
-
algorithms can eliminate elements by
|
| 310 |
-
|
| 311 |
|
| 312 |
``` cpp
|
| 313 |
template<class InputIterator, class OutputIterator, class T>
|
| 314 |
OutputIterator
|
| 315 |
remove_copy(InputIterator first, InputIterator last,
|
|
@@ -321,22 +323,22 @@ template<class InputIterator, class OutputIterator, class Predicate>
|
|
| 321 |
OutputIterator result, Predicate pred);
|
| 322 |
```
|
| 323 |
|
| 324 |
*Requires:* The ranges \[`first`, `last`) and \[`result`,
|
| 325 |
`result + (last - first)`) shall not overlap. The expression
|
| 326 |
-
`*result = *first` shall
|
| 327 |
|
| 328 |
*Effects:* Copies all the elements referred to by the iterator `i` in
|
| 329 |
the range \[`first`, `last`) for which the following corresponding
|
| 330 |
conditions do not hold: `*i == value, pred(*i) != false`.
|
| 331 |
|
| 332 |
*Returns:* The end of the resulting range.
|
| 333 |
|
| 334 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 335 |
predicate.
|
| 336 |
|
| 337 |
-
*Remarks:* Stable.
|
| 338 |
|
| 339 |
### Unique <a id="alg.unique">[[alg.unique]]</a>
|
| 340 |
|
| 341 |
``` cpp
|
| 342 |
template<class ForwardIterator>
|
|
@@ -398,13 +400,12 @@ applications of the corresponding predicate.
|
|
| 398 |
``` cpp
|
| 399 |
template<class BidirectionalIterator>
|
| 400 |
void reverse(BidirectionalIterator first, BidirectionalIterator last);
|
| 401 |
```
|
| 402 |
|
| 403 |
-
*Effects:* For each non-negative integer `i <
|
| 404 |
-
|
| 405 |
-
`first + i, (last - i) - 1`.
|
| 406 |
|
| 407 |
*Requires:* `*first` shall be swappable ([[swappable.requirements]]).
|
| 408 |
|
| 409 |
*Complexity:* Exactly `(last - first)/2` swaps.
|
| 410 |
|
|
@@ -414,13 +415,13 @@ template<class BidirectionalIterator, class OutputIterator>
|
|
| 414 |
reverse_copy(BidirectionalIterator first,
|
| 415 |
BidirectionalIterator last, OutputIterator result);
|
| 416 |
```
|
| 417 |
|
| 418 |
*Effects:* Copies the range \[`first`, `last`) to the range \[`result`,
|
| 419 |
-
`result+(last-first)`) such that for
|
| 420 |
`i < (last - first)` the following assignment takes place:
|
| 421 |
-
`*(result + (last - first) - i) = *(first + i)`.
|
| 422 |
|
| 423 |
*Requires:* The ranges \[`first`, `last`) and \[`result`,
|
| 424 |
`result+(last-first)`) shall not overlap.
|
| 425 |
|
| 426 |
*Returns:* `result + (last - first)`.
|
|
@@ -443,12 +444,12 @@ the element from the position `first + i` into position
|
|
| 443 |
|
| 444 |
*Remarks:* This is a left rotate.
|
| 445 |
|
| 446 |
*Requires:* \[`first`, `middle`) and \[`middle`, `last`) shall be valid
|
| 447 |
ranges. `ForwardIterator` shall satisfy the requirements of
|
| 448 |
-
ValueSwappable ([[swappable.requirements]]). The type of `*first`
|
| 449 |
-
satisfy the requirements of `MoveConstructible`
|
| 450 |
(Table [[moveconstructible]]) and the requirements of `MoveAssignable`
|
| 451 |
(Table [[moveassignable]]).
|
| 452 |
|
| 453 |
*Complexity:* At most `last - first` swaps.
|
| 454 |
|
|
@@ -469,22 +470,13 @@ template<class ForwardIterator, class OutputIterator>
|
|
| 469 |
*Requires:* The ranges \[`first`, `last`) and \[`result`,
|
| 470 |
`result + (last - first)`) shall not overlap.
|
| 471 |
|
| 472 |
*Complexity:* Exactly `last - first` assignments.
|
| 473 |
|
| 474 |
-
###
|
| 475 |
|
| 476 |
``` cpp
|
| 477 |
-
template<class RandomAccessIterator>
|
| 478 |
-
void random_shuffle(RandomAccessIterator first,
|
| 479 |
-
RandomAccessIterator last);
|
| 480 |
-
|
| 481 |
-
template<class RandomAccessIterator, class RandomNumberGenerator>
|
| 482 |
-
void random_shuffle(RandomAccessIterator first,
|
| 483 |
-
RandomAccessIterator last,
|
| 484 |
-
RandomNumberGenerator&& rand);
|
| 485 |
-
|
| 486 |
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
| 487 |
void shuffle(RandomAccessIterator first,
|
| 488 |
RandomAccessIterator last,
|
| 489 |
UniformRandomNumberGenerator&& g);
|
| 490 |
```
|
|
@@ -492,35 +484,20 @@ template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
|
| 492 |
*Effects:* Permutes the elements in the range \[`first`, `last`) such
|
| 493 |
that each possible permutation of those elements has equal probability
|
| 494 |
of appearance.
|
| 495 |
|
| 496 |
*Requires:* `RandomAccessIterator` shall satisfy the requirements of
|
| 497 |
-
`ValueSwappable` ([[swappable.requirements]]). The
|
| 498 |
-
generating function object `rand` shall have a return type that is
|
| 499 |
-
convertible to `iterator_traits<RandomAccessIterator>::difference_type`,
|
| 500 |
-
and the call `rand(n)` shall return a randomly chosen value in the
|
| 501 |
-
interval \[`0`, `n`), for `n > 0` of type
|
| 502 |
-
`iterator_traits<RandomAccessIterator>::difference_type`. The type
|
| 503 |
`UniformRandomNumberGenerator` shall meet the requirements of a uniform
|
| 504 |
random number generator ([[rand.req.urng]]) type whose return type is
|
| 505 |
convertible to `iterator_traits<RandomAccessIterator>::difference_type`.
|
| 506 |
|
| 507 |
*Complexity:* Exactly `(last - first) - 1` swaps.
|
| 508 |
|
| 509 |
-
*Remarks:* To the extent that the implementation of
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
The underlying source of random numbers for the first form of the
|
| 514 |
-
function is *implementation-defined*. An implementation may use the
|
| 515 |
-
`rand` function from the standard C library.
|
| 516 |
-
|
| 517 |
-
In the second form of the function, the function object `rand` shall
|
| 518 |
-
serve as the implementation’s source of randomness.
|
| 519 |
-
|
| 520 |
-
In the third `shuffle` form of the function, the object `g` shall serve
|
| 521 |
-
as the implementation’s source of randomness.
|
| 522 |
|
| 523 |
### Partitions <a id="alg.partitions">[[alg.partitions]]</a>
|
| 524 |
|
| 525 |
``` cpp
|
| 526 |
template <class InputIterator, class Predicate>
|
|
@@ -544,12 +521,12 @@ template<class ForwardIterator, class Predicate>
|
|
| 544 |
```
|
| 545 |
|
| 546 |
*Effects:* Places all the elements in the range \[`first`, `last`) that
|
| 547 |
satisfy `pred` before all the elements that do not satisfy it.
|
| 548 |
|
| 549 |
-
*Returns:* An iterator `i` such that for
|
| 550 |
-
\[`first`, `i`) `pred(*j) != false`, and for
|
| 551 |
range \[`i`, `last`), `pred(*k) == false`.
|
| 552 |
|
| 553 |
*Requires:* `ForwardIterator` shall satisfy the requirements of
|
| 554 |
`ValueSwappable` ([[swappable.requirements]]).
|
| 555 |
|
|
@@ -566,12 +543,12 @@ template<class BidirectionalIterator, class Predicate>
|
|
| 566 |
```
|
| 567 |
|
| 568 |
*Effects:* Places all the elements in the range \[`first`, `last`) that
|
| 569 |
satisfy `pred` before all the elements that do not satisfy it.
|
| 570 |
|
| 571 |
-
*Returns:* An iterator `i` such that for
|
| 572 |
-
\[`first`, `i`), `pred(*j) != false`, and for
|
| 573 |
range \[`i`, `last`), `pred(*k) == false`. The relative order of the
|
| 574 |
elements in both groups is preserved.
|
| 575 |
|
| 576 |
*Requires:* `BidirectionalIterator` shall satisfy the requirements of
|
| 577 |
`ValueSwappable` ([[swappable.requirements]]). The type of `*first`
|
|
@@ -590,13 +567,13 @@ template <class InputIterator, class OutputIterator1,
|
|
| 590 |
partition_copy(InputIterator first, InputIterator last,
|
| 591 |
OutputIterator1 out_true, OutputIterator2 out_false,
|
| 592 |
Predicate pred);
|
| 593 |
```
|
| 594 |
|
| 595 |
-
*Requires:* `InputIterator`’s value type shall be
|
| 596 |
-
be writable to the `out_true` and `out_false` `OutputIterator`s,
|
| 597 |
-
shall be convertible to `Predicate`’s argument type. The input range
|
| 598 |
shall not overlap with either of the output ranges.
|
| 599 |
|
| 600 |
*Effects:* For each iterator `i` in \[`first`, `last`), copies `*i` to
|
| 601 |
the output range beginning with `out_true` if `pred(*i)` is `true`, or
|
| 602 |
to the output range beginning with `out_false` otherwise.
|
|
|
|
| 42 |
`result + (last - first)`) shall not overlap.
|
| 43 |
|
| 44 |
*Effects:* Copies all of the elements referred to by the iterator `i` in
|
| 45 |
the range \[`first`, `last`) for which `pred(*i)` is `true`.
|
| 46 |
|
| 47 |
+
*Returns:* The end of the resulting range.
|
| 48 |
+
|
| 49 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 50 |
predicate.
|
| 51 |
|
| 52 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
template<class BidirectionalIterator1, class BidirectionalIterator2>
|
| 56 |
BidirectionalIterator2
|
| 57 |
copy_backward(BidirectionalIterator1 first,
|
|
|
|
| 299 |
the range \[`first`, `last`) for which the following corresponding
|
| 300 |
conditions hold: `*i == value, pred(*i) != false`.
|
| 301 |
|
| 302 |
*Returns:* The end of the resulting range.
|
| 303 |
|
| 304 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 305 |
|
| 306 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 307 |
predicate.
|
| 308 |
|
| 309 |
*Note:* each element in the range \[`ret`, `last`), where `ret` is the
|
| 310 |
returned value, has a valid but unspecified state, because the
|
| 311 |
+
algorithms can eliminate elements by moving from elements that were
|
| 312 |
+
originally in that range.
|
| 313 |
|
| 314 |
``` cpp
|
| 315 |
template<class InputIterator, class OutputIterator, class T>
|
| 316 |
OutputIterator
|
| 317 |
remove_copy(InputIterator first, InputIterator last,
|
|
|
|
| 323 |
OutputIterator result, Predicate pred);
|
| 324 |
```
|
| 325 |
|
| 326 |
*Requires:* The ranges \[`first`, `last`) and \[`result`,
|
| 327 |
`result + (last - first)`) shall not overlap. The expression
|
| 328 |
+
`*result = *first` shall be valid.
|
| 329 |
|
| 330 |
*Effects:* Copies all the elements referred to by the iterator `i` in
|
| 331 |
the range \[`first`, `last`) for which the following corresponding
|
| 332 |
conditions do not hold: `*i == value, pred(*i) != false`.
|
| 333 |
|
| 334 |
*Returns:* The end of the resulting range.
|
| 335 |
|
| 336 |
*Complexity:* Exactly `last - first` applications of the corresponding
|
| 337 |
predicate.
|
| 338 |
|
| 339 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 340 |
|
| 341 |
### Unique <a id="alg.unique">[[alg.unique]]</a>
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
template<class ForwardIterator>
|
|
|
|
| 400 |
``` cpp
|
| 401 |
template<class BidirectionalIterator>
|
| 402 |
void reverse(BidirectionalIterator first, BidirectionalIterator last);
|
| 403 |
```
|
| 404 |
|
| 405 |
+
*Effects:* For each non-negative integer `i < (last - first)/2`, applies
|
| 406 |
+
`iter_swap` to all pairs of iterators `first + i, (last - i) - 1`.
|
|
|
|
| 407 |
|
| 408 |
*Requires:* `*first` shall be swappable ([[swappable.requirements]]).
|
| 409 |
|
| 410 |
*Complexity:* Exactly `(last - first)/2` swaps.
|
| 411 |
|
|
|
|
| 415 |
reverse_copy(BidirectionalIterator first,
|
| 416 |
BidirectionalIterator last, OutputIterator result);
|
| 417 |
```
|
| 418 |
|
| 419 |
*Effects:* Copies the range \[`first`, `last`) to the range \[`result`,
|
| 420 |
+
`result+(last-first)`) such that for every non-negative integer
|
| 421 |
`i < (last - first)` the following assignment takes place:
|
| 422 |
+
`*(result + (last - first) - 1 - i) = *(first + i)`.
|
| 423 |
|
| 424 |
*Requires:* The ranges \[`first`, `last`) and \[`result`,
|
| 425 |
`result+(last-first)`) shall not overlap.
|
| 426 |
|
| 427 |
*Returns:* `result + (last - first)`.
|
|
|
|
| 444 |
|
| 445 |
*Remarks:* This is a left rotate.
|
| 446 |
|
| 447 |
*Requires:* \[`first`, `middle`) and \[`middle`, `last`) shall be valid
|
| 448 |
ranges. `ForwardIterator` shall satisfy the requirements of
|
| 449 |
+
`ValueSwappable` ([[swappable.requirements]]). The type of `*first`
|
| 450 |
+
shall satisfy the requirements of `MoveConstructible`
|
| 451 |
(Table [[moveconstructible]]) and the requirements of `MoveAssignable`
|
| 452 |
(Table [[moveassignable]]).
|
| 453 |
|
| 454 |
*Complexity:* At most `last - first` swaps.
|
| 455 |
|
|
|
|
| 470 |
*Requires:* The ranges \[`first`, `last`) and \[`result`,
|
| 471 |
`result + (last - first)`) shall not overlap.
|
| 472 |
|
| 473 |
*Complexity:* Exactly `last - first` assignments.
|
| 474 |
|
| 475 |
+
### Shuffle <a id="alg.random.shuffle">[[alg.random.shuffle]]</a>
|
| 476 |
|
| 477 |
``` cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
| 479 |
void shuffle(RandomAccessIterator first,
|
| 480 |
RandomAccessIterator last,
|
| 481 |
UniformRandomNumberGenerator&& g);
|
| 482 |
```
|
|
|
|
| 484 |
*Effects:* Permutes the elements in the range \[`first`, `last`) such
|
| 485 |
that each possible permutation of those elements has equal probability
|
| 486 |
of appearance.
|
| 487 |
|
| 488 |
*Requires:* `RandomAccessIterator` shall satisfy the requirements of
|
| 489 |
+
`ValueSwappable` ([[swappable.requirements]]). The type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
`UniformRandomNumberGenerator` shall meet the requirements of a uniform
|
| 491 |
random number generator ([[rand.req.urng]]) type whose return type is
|
| 492 |
convertible to `iterator_traits<RandomAccessIterator>::difference_type`.
|
| 493 |
|
| 494 |
*Complexity:* Exactly `(last - first) - 1` swaps.
|
| 495 |
|
| 496 |
+
*Remarks:* To the extent that the implementation of this function makes
|
| 497 |
+
use of random numbers, the object `g` shall serve as the
|
| 498 |
+
implementation’s source of randomness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
|
| 500 |
### Partitions <a id="alg.partitions">[[alg.partitions]]</a>
|
| 501 |
|
| 502 |
``` cpp
|
| 503 |
template <class InputIterator, class Predicate>
|
|
|
|
| 521 |
```
|
| 522 |
|
| 523 |
*Effects:* Places all the elements in the range \[`first`, `last`) that
|
| 524 |
satisfy `pred` before all the elements that do not satisfy it.
|
| 525 |
|
| 526 |
+
*Returns:* An iterator `i` such that for every iterator `j` in the range
|
| 527 |
+
\[`first`, `i`) `pred(*j) != false`, and for every iterator `k` in the
|
| 528 |
range \[`i`, `last`), `pred(*k) == false`.
|
| 529 |
|
| 530 |
*Requires:* `ForwardIterator` shall satisfy the requirements of
|
| 531 |
`ValueSwappable` ([[swappable.requirements]]).
|
| 532 |
|
|
|
|
| 543 |
```
|
| 544 |
|
| 545 |
*Effects:* Places all the elements in the range \[`first`, `last`) that
|
| 546 |
satisfy `pred` before all the elements that do not satisfy it.
|
| 547 |
|
| 548 |
+
*Returns:* An iterator `i` such that for every iterator `j` in the range
|
| 549 |
+
\[`first`, `i`), `pred(*j) != false`, and for every iterator `k` in the
|
| 550 |
range \[`i`, `last`), `pred(*k) == false`. The relative order of the
|
| 551 |
elements in both groups is preserved.
|
| 552 |
|
| 553 |
*Requires:* `BidirectionalIterator` shall satisfy the requirements of
|
| 554 |
`ValueSwappable` ([[swappable.requirements]]). The type of `*first`
|
|
|
|
| 567 |
partition_copy(InputIterator first, InputIterator last,
|
| 568 |
OutputIterator1 out_true, OutputIterator2 out_false,
|
| 569 |
Predicate pred);
|
| 570 |
```
|
| 571 |
|
| 572 |
+
*Requires:* `InputIterator`’s value type shall be `CopyAssignable`, and
|
| 573 |
+
shall be writable to the `out_true` and `out_false` `OutputIterator`s,
|
| 574 |
+
and shall be convertible to `Predicate`’s argument type. The input range
|
| 575 |
shall not overlap with either of the output ranges.
|
| 576 |
|
| 577 |
*Effects:* For each iterator `i` in \[`first`, `last`), copies `*i` to
|
| 578 |
the output range beginning with `out_true` if `pred(*i)` is `true`, or
|
| 579 |
to the output range beginning with `out_false` otherwise.
|