mirror of
https://github.com/boostorg/mpi.git
synced 2026-01-19 04:22:10 +00:00
Move from std::random_shuffle to std::shuffle
This commit is contained in:
@@ -20,7 +20,8 @@
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/graph/iteration_macros.hpp>
|
||||
#include <boost/graph/isomorphism.hpp>
|
||||
#include <algorithm> // for random_shuffle
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/mpi/collectives/broadcast.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@@ -28,24 +29,6 @@
|
||||
#define BOOST_TEST_MODULE mpi_graph_topology
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX98_RANDOM_SHUFFLE)
|
||||
|
||||
#include <random>
|
||||
|
||||
std::default_random_engine gen;
|
||||
|
||||
template<typename RandomIt> void random_shuffle( RandomIt first, RandomIt last )
|
||||
{
|
||||
std::shuffle( first, last, gen );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
using std::random_shuffle;
|
||||
|
||||
#endif // #if defined(BOOST_NO_CXX98_RANDOM_SHUFFLE)
|
||||
|
||||
|
||||
using boost::mpi::communicator;
|
||||
using boost::mpi::graph_communicator;
|
||||
using namespace boost;
|
||||
@@ -94,7 +77,11 @@ BOOST_AUTO_TEST_CASE(graph_topology)
|
||||
BGL_FORALL_VERTICES(v, graph, Graph)
|
||||
put(graph_alt_index, v, index++);
|
||||
|
||||
::random_shuffle(graph_alt_index_vec.begin(), graph_alt_index_vec.end());
|
||||
{
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::shuffle(graph_alt_index_vec.begin(), graph_alt_index_vec.end(), gen);
|
||||
}
|
||||
}
|
||||
broadcast(world, graph_alt_index_vec, 0);
|
||||
|
||||
|
||||
@@ -20,31 +20,15 @@
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/graph/iteration_macros.hpp>
|
||||
#include <boost/graph/isomorphism.hpp>
|
||||
#include <algorithm> // for random_shuffle
|
||||
#include <algorithm> // for shuffle
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/mpi/collectives/broadcast.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include "mpi_test_utils.hpp"
|
||||
|
||||
#if defined(BOOST_NO_CXX98_RANDOM_SHUFFLE)
|
||||
|
||||
#include <random>
|
||||
|
||||
std::default_random_engine gen;
|
||||
|
||||
template<typename RandomIt> void random_shuffle( RandomIt first, RandomIt last )
|
||||
{
|
||||
std::shuffle( first, last, gen );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
using std::random_shuffle;
|
||||
|
||||
#endif // #if defined(BOOST_NO_CXX98_RANDOM_SHUFFLE)
|
||||
|
||||
|
||||
using boost::mpi::communicator;
|
||||
using boost::mpi::graph_communicator;
|
||||
using namespace boost;
|
||||
@@ -93,7 +77,11 @@ int main()
|
||||
BGL_FORALL_VERTICES(v, graph, Graph)
|
||||
put(graph_alt_index, v, index++);
|
||||
|
||||
::random_shuffle(graph_alt_index_vec.begin(), graph_alt_index_vec.end());
|
||||
{
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::shuffle(graph_alt_index_vec.begin(), graph_alt_index_vec.end(), gen);
|
||||
}
|
||||
}
|
||||
broadcast(world, graph_alt_index_vec, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user