template< class RandomIt >
void shuffle( RandomIt first, RandomIt last );
Reorders the elements in the given range [
first,
last)
such that each possible permutation of those elements has equal probability of appearance, using the per-thread random number engine as the random number generator.
(none)
[edit] ComplexityLinear in the distance between first and last.
[edit] Example#include <experimental/algorithm> #include <iostream> #include <string> int main() { std::string sample{"ABCDEF"}; for (int i = 0; i != 4; ++i) { std::experimental::shuffle(sample.begin(), sample.end()); std::cout << sample << '\n'; } }
Possible output:
DACBFE CDFBAE BDCAFE BAFCED[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4