• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[/
2    Copyright 2010 Neil Groves
3    Distributed under the Boost Software License, Version 1.0.
4    (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5/]
6[section:random_shuffle random_shuffle]
7
8[heading Prototype]
9
10``
11template<class RandomAccessRange>
12RandomAccessRange& random_shuffle(RandomAccessRange& rng);
13
14template<class RandomAccessRange>
15const RandomAccessRange& random_shuffle(const RandomAccessRange& rng);
16
17template<class RandomAccessRange, class Generator>
18RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen);
19
20template<class RandomAccessRange, class Generator>
21const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen);
22``
23
24[heading Description]
25
26`random_shuffle` randomly rearranges the elements in `rng`. The versions of `random_shuffle` that do not specify a `Generator` use an internal random number generator. The versions of `random_shuffle` that do specify a `Generator` use this instead. Returns the shuffles range.
27
28[heading Definition]
29
30Defined in the header file `boost/range/algorithm/random_shuffle.hpp`
31
32[heading Requirements]
33
34[*For the version without a Generator:]
35
36* `RandomAccessRange` is a model of the __random_access_range__ Concept.
37
38[*For the version with a Generator:]
39
40* `RandomAccessRange` is a model of the __random_access_range__ Concept.
41* `Generator` is a model of the `RandomNumberGeneratorConcept`.
42* `RandomAccessRange`'s distance type is convertible to `Generator`'s argument type.
43
44[heading Precondition:]
45
46* `distance(rng)` is less than `gen`'s maximum value.
47
48
49[heading Complexity]
50
51Linear. If `!empty(rng)`, exactly `distance(rng) - 1` swaps are performed.
52
53[endsect]
54
55
56