fix: fix deprecation warning for macOS (#2711)

Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
This commit is contained in:
Maxim Smolskiy
2024-08-31 04:05:53 +03:00
committed by GitHub
parent 4a03c62dd3
commit 1f5828eadf

View File

@@ -18,6 +18,7 @@
#include <algorithm>
#include <array>
#include <cassert>
#include <random>
/**
@@ -50,8 +51,10 @@ std::array <T, N> shuffle (std::array <T, N> arr) {
template <typename T, size_t N>
std::array <T, N> randomized_bogosort (std::array <T, N> arr) {
// Untill array is not sorted
std::random_device random_device;
std::mt19937 generator(random_device());
while (!std::is_sorted(arr.begin(), arr.end())) {
std::random_shuffle(arr.begin(), arr.end());// Shuffle the array
std::shuffle(arr.begin(), arr.end(), generator);// Shuffle the array
}
return arr;
}