New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
random_shuffle.hpp in vendors/XIOS/current/extern/boost/include/boost/range/algorithm – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/range/algorithm/random_shuffle.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 2.1 KB
Line 
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)
5//
6//
7// For more information, see http://www.boost.org/libs/range/
8//
9#ifndef BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
10#define BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
11
12#include <boost/concept_check.hpp>
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15#include <boost/range/concepts.hpp>
16#include <algorithm>
17
18namespace boost
19{
20    namespace range
21    {
22
23/// \brief template function random_shuffle
24///
25/// range-based version of the random_shuffle std algorithm
26///
27/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
28/// \pre Generator is a model of the UnaryFunctionConcept
29template<class RandomAccessRange>
30inline RandomAccessRange& random_shuffle(RandomAccessRange& rng)
31{
32    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
33    std::random_shuffle(boost::begin(rng), boost::end(rng));
34    return rng;
35}
36
37/// \overload
38template<class RandomAccessRange>
39inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng)
40{
41    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
42    std::random_shuffle(boost::begin(rng), boost::end(rng));
43    return rng;
44}
45
46/// \overload
47template<class RandomAccessRange, class Generator>
48inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen)
49{
50    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
51    std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
52    return rng;
53}
54
55/// \overload
56template<class RandomAccessRange, class Generator>
57inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen)
58{
59    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
60    std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
61    return rng;
62}
63
64    } // namespace range
65    using range::random_shuffle;
66} // namespace boost
67
68#endif // include guard
Note: See TracBrowser for help on using the repository browser.