-
Notifications
You must be signed in to change notification settings - Fork 29
/
algorithms.html
61 lines (51 loc) · 2.59 KB
/
algorithms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<cxx-clause id="algorithms">
<h1>Algorithms library</h1>
<cxx-section id="algorithm.syn">
<h1>Header <code><experimental/algorithm></code> synopsis</h1>
<pre><code>#include <algorithm>
namespace std::experimental::inline fundamentals_v3 {
<cxx-ref insynopsis="" to="alg.random.sample"></cxx-ref>
template<class PopulationIterator, class SampleIterator, class Distance>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n);
<cxx-ref insynopsis="" to="alg.random.shuffle"></cxx-ref>
template<class RandomAccessIterator>
void shuffle(RandomAccessIterator first, RandomAccessIterator last);
} // namespace std::experimental::inline fundamentals_v3</code></pre>
</cxx-section>
<cxx-section id="alg.random.sample">
<h1>Sampling</h1>
<cxx-function>
<cxx-signature class="formatted">template<class PopulationIterator, class SampleIterator, class Distance>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n);</cxx-signature>
<cxx-effects>
Equivalent to:
<pre><code>return ::std::sample(first, last, out, n, g);</code></pre>
where <code>g</code> denotes
the per-thread engine (<cxx-ref to="rand.randint"></cxx-ref>).
To the extent that the implementation of this function makes use of
random numbers, the object <code>g</code> serves as the
implementation’s source of randomness.
</cxx-effects>
</cxx-function>
</cxx-section>
<cxx-section id="alg.random.shuffle">
<h1>Shuffle</h1>
<cxx-function>
<cxx-signature>template<class RandomAccessIterator>
void shuffle(RandomAccessIterator first, RandomAccessIterator last);</cxx-signature>
<cxx-preconditions><code>RandomAccessIterator</code> meets the
<cxx-17concept>Cpp17ValueSwappable</cxx-17concept> requirements (<cxx-ref in="cxx" to="swappable.requirements"></cxx-ref>).
</cxx-preconditions>
<cxx-effects>Permutes the elements in the range <code>[first,last)</code>
such that each possible permutation of those elements has equal
probability of appearance.</cxx-effects>
<cxx-complexity>Exactly <code>(last - first) - 1</code> swaps.</cxx-complexity>
<cxx-remarks>To the extent that the implementation of this function
makes use of random numbers, the per-thread engine (<cxx-ref to="rand.randint"></cxx-ref>)
serves as the implementation's source of randomness.
</cxx-remarks>
</cxx-function>
</cxx-section>
</cxx-clause>