tmp/tmp66p1hfqm/{from.md → to.md}
RENAMED
|
@@ -1,17 +1,8 @@
|
|
| 1 |
-
###
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
-
template<class RandomAccessIterator>
|
| 5 |
-
void random_shuffle(RandomAccessIterator first,
|
| 6 |
-
RandomAccessIterator last);
|
| 7 |
-
|
| 8 |
-
template<class RandomAccessIterator, class RandomNumberGenerator>
|
| 9 |
-
void random_shuffle(RandomAccessIterator first,
|
| 10 |
-
RandomAccessIterator last,
|
| 11 |
-
RandomNumberGenerator&& rand);
|
| 12 |
-
|
| 13 |
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
| 14 |
void shuffle(RandomAccessIterator first,
|
| 15 |
RandomAccessIterator last,
|
| 16 |
UniformRandomNumberGenerator&& g);
|
| 17 |
```
|
|
@@ -19,31 +10,16 @@ template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
|
| 19 |
*Effects:* Permutes the elements in the range \[`first`, `last`) such
|
| 20 |
that each possible permutation of those elements has equal probability
|
| 21 |
of appearance.
|
| 22 |
|
| 23 |
*Requires:* `RandomAccessIterator` shall satisfy the requirements of
|
| 24 |
-
`ValueSwappable` ([[swappable.requirements]]). The
|
| 25 |
-
generating function object `rand` shall have a return type that is
|
| 26 |
-
convertible to `iterator_traits<RandomAccessIterator>::difference_type`,
|
| 27 |
-
and the call `rand(n)` shall return a randomly chosen value in the
|
| 28 |
-
interval \[`0`, `n`), for `n > 0` of type
|
| 29 |
-
`iterator_traits<RandomAccessIterator>::difference_type`. The type
|
| 30 |
`UniformRandomNumberGenerator` shall meet the requirements of a uniform
|
| 31 |
random number generator ([[rand.req.urng]]) type whose return type is
|
| 32 |
convertible to `iterator_traits<RandomAccessIterator>::difference_type`.
|
| 33 |
|
| 34 |
*Complexity:* Exactly `(last - first) - 1` swaps.
|
| 35 |
|
| 36 |
-
*Remarks:* To the extent that the implementation of
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
The underlying source of random numbers for the first form of the
|
| 41 |
-
function is *implementation-defined*. An implementation may use the
|
| 42 |
-
`rand` function from the standard C library.
|
| 43 |
-
|
| 44 |
-
In the second form of the function, the function object `rand` shall
|
| 45 |
-
serve as the implementation’s source of randomness.
|
| 46 |
-
|
| 47 |
-
In the third `shuffle` form of the function, the object `g` shall serve
|
| 48 |
-
as the implementation’s source of randomness.
|
| 49 |
|
|
|
|
| 1 |
+
### Shuffle <a id="alg.random.shuffle">[[alg.random.shuffle]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
|
| 5 |
void shuffle(RandomAccessIterator first,
|
| 6 |
RandomAccessIterator last,
|
| 7 |
UniformRandomNumberGenerator&& g);
|
| 8 |
```
|
|
|
|
| 10 |
*Effects:* Permutes the elements in the range \[`first`, `last`) such
|
| 11 |
that each possible permutation of those elements has equal probability
|
| 12 |
of appearance.
|
| 13 |
|
| 14 |
*Requires:* `RandomAccessIterator` shall satisfy the requirements of
|
| 15 |
+
`ValueSwappable` ([[swappable.requirements]]). The type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
`UniformRandomNumberGenerator` shall meet the requirements of a uniform
|
| 17 |
random number generator ([[rand.req.urng]]) type whose return type is
|
| 18 |
convertible to `iterator_traits<RandomAccessIterator>::difference_type`.
|
| 19 |
|
| 20 |
*Complexity:* Exactly `(last - first) - 1` swaps.
|
| 21 |
|
| 22 |
+
*Remarks:* To the extent that the implementation of this function makes
|
| 23 |
+
use of random numbers, the object `g` shall serve as the
|
| 24 |
+
implementation’s source of randomness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|