Randomly shuffle order of elements in a vecrot or array

Hello,

I’m looking for a function that randomly shuffles the order of elements in a vector or array. I think I once used an oF function which did just that, but I don’t remember which one it was and I can’t find it.
Can anybody give me a hint?

Thanks!

I don’t know of an openFrameworks function for that, but there is a C++ standard library function for it called random_shuffle. See the example below.

#include <algorithm>

std::vector<int> v = { 1,2,3 };
std::random_shuffle(v.begin(), v.end());

Here is a reference page for it: http://en.cppreference.com/w/cpp/algorithm/random_shuffle

Cool! Thank you very much!