24.4.2 Transformations - random_shuffle
- random_shuffle - random permutation on elements
- Like a deck of cards
- Uses random access iterators
- Only useful with vector, deque, array
- E.g., vector might hold Cards instead of ints:
vector<int> a(10);
generate(a.begin(), a.end(), SequenceGenerator(1));
// Initially
1, 2, . . . 10
random_shuffle(a.begin(), a.end());
- Can't predict the actual sequence
prev
|top
|next