GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::experimental::shuffle(3) C++ Standard Libary std::experimental::shuffle(3)

std::experimental::shuffle - std::experimental::shuffle


Defined in header <experimental/algorithm>
template< class RandomIt> (library fundamentals TS v2)
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.


first, last - the range of elements to shuffle randomly
-
RandomIt must meet the requirements of ValueSwappable and
LegacyRandomAccessIterator.


(none)


Linear in the distance between first and last.

// Run this code


#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';
}
}


DACBFE
CDFBAE
BDCAFE
BAFCED


random_shuffle
shuffle randomly re-orders elements in a range
(until C++17) (function template)
(C++11)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.