Declaration
template <class RandomAccessIterator> inline void random_shuffle(RandomAccessIterator first, RandomAccessIterator last); template <class RandomAccessIterator, class RandomNumberGenerator> void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator& rand);
Description The random_shuffle functions randomly shuffle the elements in the range [ first, last) with uniform distribution .
Type requirements
Group Mutating sequence operations.
Time complexity Linear.
The number of swaps performed is one less than the size of the range [ first, last) .
Space complexity Constant.
Mutative? Yes.
Example Select here to view the source code for the example.
Implementation Select here to view source code (Copyright (C) 1994, Hewlett-Packard Company) for this algorithm.