Skip to content

Commit

Permalink
[T] Replace std::random_shuffle with std::shuffle.
Browse files Browse the repository at this point in the history
The latter takes a random generator while the former uses
std::rand implicitly.
The std::random_shuffle was marked deprecated and is removed
from the c++17.
  • Loading branch information
endJunction authored and bilke committed Dec 19, 2018
1 parent 8dd3059 commit f3017bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Tests/BaseLib/TestAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <algorithm>
#include <numeric>
#include <random>
#include <vector>

#include <gtest/gtest.h>
Expand All @@ -19,12 +20,13 @@ TEST(BaseLibAlgorithm, testreorderVector)
{
const std::size_t size = 100;
std::vector<double> vec(size);
std::generate(vec.begin(), vec.end(), std::rand);
std::default_random_engine random_engine;
std::generate(vec.begin(), vec.end(), random_engine);
std::vector<double> vec0 = vec;

std::vector<int> order(size);
std::iota(order.begin(), order.end(), 0);
std::random_shuffle(order.begin(), order.end());
std::shuffle(order.begin(), order.end(), random_engine);

BaseLib::reorderVector(vec, order);

Expand Down

0 comments on commit f3017bd

Please sign in to comment.