tmp/tmpid7lo2s5/{from.md → to.md}
RENAMED
|
@@ -4,31 +4,41 @@
|
|
| 4 |
template<class PopulationIterator, class SampleIterator,
|
| 5 |
class Distance, class UniformRandomBitGenerator>
|
| 6 |
SampleIterator sample(PopulationIterator first, PopulationIterator last,
|
| 7 |
SampleIterator out, Distance n,
|
| 8 |
UniformRandomBitGenerator&& g);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
```
|
| 10 |
|
| 11 |
-
*
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
- `SampleIterator` shall satisfy the requirements of an output
|
| 16 |
-
iterator ([[output.iterators]]).
|
| 17 |
-
- `SampleIterator` shall satisfy the additional requirements of a random
|
| 18 |
-
access iterator ([[random.access.iterators]]) unless
|
| 19 |
-
`PopulationIterator` satisfies the additional requirements of a
|
| 20 |
-
forward iterator ([[forward.iterators]]).
|
| 21 |
-
- `PopulationIterator`’s value type shall be
|
| 22 |
-
writable ([[iterator.requirements.general]]) to `out`.
|
| 23 |
-
- `Distance` shall be an integer type.
|
| 24 |
-
- `remove_reference_t<UniformRandomBitGenerator>` shall meet the
|
| 25 |
-
requirements of a uniform random bit generator type
|
| 26 |
-
([[rand.req.urng]]) whose return type is convertible to `Distance`.
|
| 27 |
-
- `out` shall not be in the range \[`first`, `last`).
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
\[`first`, `last`) (the *population*) to `out` such that each possible
|
| 31 |
sample has equal probability of appearance.
|
| 32 |
|
| 33 |
[*Note 1*: Algorithms that obtain such effects include *selection
|
| 34 |
sampling* and *reservoir sampling*. — *end note*]
|
|
@@ -37,11 +47,13 @@ sampling* and *reservoir sampling*. — *end note*]
|
|
| 37 |
|
| 38 |
*Complexity:* 𝑂(`last - first`).
|
| 39 |
|
| 40 |
*Remarks:*
|
| 41 |
|
| 42 |
-
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
- To the extent that the implementation of this function makes use of
|
| 45 |
-
random numbers, the object `g`
|
| 46 |
-
|
| 47 |
|
|
|
|
| 4 |
template<class PopulationIterator, class SampleIterator,
|
| 5 |
class Distance, class UniformRandomBitGenerator>
|
| 6 |
SampleIterator sample(PopulationIterator first, PopulationIterator last,
|
| 7 |
SampleIterator out, Distance n,
|
| 8 |
UniformRandomBitGenerator&& g);
|
| 9 |
+
|
| 10 |
+
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
|
| 11 |
+
requires (forward_iterator<I> || random_access_iterator<O>) &&
|
| 12 |
+
indirectly_copyable<I, O> &&
|
| 13 |
+
uniform_random_bit_generator<remove_reference_t<Gen>>
|
| 14 |
+
O ranges::sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g);
|
| 15 |
+
template<input_range R, weakly_incrementable O, class Gen>
|
| 16 |
+
requires (forward_range<R> || random_access_iterator<O>) &&
|
| 17 |
+
indirectly_copyable<iterator_t<R>, O> &&
|
| 18 |
+
uniform_random_bit_generator<remove_reference_t<Gen>>
|
| 19 |
+
O ranges::sample(R&& r, O out, range_difference_t<R> n, Gen&& g);
|
| 20 |
```
|
| 21 |
|
| 22 |
+
*Mandates:* For the overload in namespace `std`, `Distance` is an
|
| 23 |
+
integer type and `*first` is writable [[iterator.requirements.general]]
|
| 24 |
+
to `out`.
|
| 25 |
|
| 26 |
+
*Preconditions:* `out` is not in the range \[`first`, `last`). For the
|
| 27 |
+
overload in namespace `std`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
- `PopulationIterator` meets the *Cpp17InputIterator*
|
| 30 |
+
requirements [[input.iterators]].
|
| 31 |
+
- `SampleIterator` meets the *Cpp17OutputIterator*
|
| 32 |
+
requirements [[output.iterators]].
|
| 33 |
+
- `SampleIterator` meets the *Cpp17RandomAccessIterator*
|
| 34 |
+
requirements [[random.access.iterators]] unless `PopulationIterator`
|
| 35 |
+
meets the *Cpp17ForwardIterator* requirements [[forward.iterators]].
|
| 36 |
+
- `remove_reference_t<UniformRandomBitGenerator>` meets the requirements
|
| 37 |
+
of a uniform random bit generator type [[rand.req.urng]].
|
| 38 |
+
|
| 39 |
+
*Effects:* Copies min(`last - first`, `n`) elements (the *sample*) from
|
| 40 |
\[`first`, `last`) (the *population*) to `out` such that each possible
|
| 41 |
sample has equal probability of appearance.
|
| 42 |
|
| 43 |
[*Note 1*: Algorithms that obtain such effects include *selection
|
| 44 |
sampling* and *reservoir sampling*. — *end note*]
|
|
|
|
| 47 |
|
| 48 |
*Complexity:* 𝑂(`last - first`).
|
| 49 |
|
| 50 |
*Remarks:*
|
| 51 |
|
| 52 |
+
- For the overload in namespace `std`, stable if and only if
|
| 53 |
+
`PopulationIterator` meets the *Cpp17ForwardIterator* requirements.
|
| 54 |
+
For the first overload in namespace `ranges`, stable if and only if
|
| 55 |
+
`I` models `forward_iterator`.
|
| 56 |
- To the extent that the implementation of this function makes use of
|
| 57 |
+
random numbers, the object `g` serves as the implementation’s source
|
| 58 |
+
of randomness.
|
| 59 |
|