Skip to content

Commit 1f5828e

Browse files
fix: fix deprecation warning for macOS (TheAlgorithms#2711)
Co-authored-by: realstealthninja <[email protected]>
1 parent 4a03c62 commit 1f5828e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sorting/bogo_sort.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <algorithm>
1919
#include <array>
2020
#include <cassert>
21+
#include <random>
2122

2223

2324
/**
@@ -50,8 +51,10 @@ std::array <T, N> shuffle (std::array <T, N> arr) {
5051
template <typename T, size_t N>
5152
std::array <T, N> randomized_bogosort (std::array <T, N> arr) {
5253
// Untill array is not sorted
54+
std::random_device random_device;
55+
std::mt19937 generator(random_device());
5356
while (!std::is_sorted(arr.begin(), arr.end())) {
54-
std::random_shuffle(arr.begin(), arr.end());// Shuffle the array
57+
std::shuffle(arr.begin(), arr.end(), generator);// Shuffle the array
5558
}
5659
return arr;
5760
}

0 commit comments

Comments
 (0)