1 // Copyright Neil Groves 2009. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org/libs/range/
9 #ifndef BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
10 #define BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
12 #include <boost/concept_check.hpp>
13 #include <boost/range/begin.hpp>
14 #include <boost/range/end.hpp>
15 #include <boost/range/concepts.hpp>
23 /// \brief template function random_shuffle
25 /// range-based version of the random_shuffle std algorithm
27 /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
28 /// \pre Generator is a model of the UnaryFunctionConcept
29 template<class RandomAccessRange>
30 inline RandomAccessRange& random_shuffle(RandomAccessRange& rng)
32 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
33 std::random_shuffle(boost::begin(rng), boost::end(rng));
38 template<class RandomAccessRange>
39 inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng)
41 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
42 std::random_shuffle(boost::begin(rng), boost::end(rng));
47 template<class RandomAccessRange, class Generator>
48 inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen)
50 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
51 std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
56 template<class RandomAccessRange, class Generator>
57 inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen)
59 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
60 std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
65 using range::random_shuffle;
68 #endif // include guard