2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <algorithm>
|
|
|
|
|
2010-08-22 02:08:10 +02:00
|
|
|
// template<RandomAccessIterator Iter>
|
|
|
|
// requires ShuffleIterator<Iter>
|
2010-05-11 21:42:16 +02:00
|
|
|
// void
|
|
|
|
// random_shuffle(Iter first, Iter last);
|
|
|
|
|
|
|
|
#include <algorithm>
|
2010-05-26 19:49:34 +02:00
|
|
|
#include <cassert>
|
2010-05-11 21:42:16 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int ia[] = {1, 2, 3, 4};
|
2010-05-26 19:49:34 +02:00
|
|
|
int ia1[] = {1, 4, 3, 2};
|
|
|
|
int ia2[] = {4, 1, 2, 3};
|
2010-05-11 21:42:16 +02:00
|
|
|
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
|
|
|
|
std::random_shuffle(ia, ia+sa);
|
2010-05-26 19:49:34 +02:00
|
|
|
assert(std::equal(ia, ia+sa, ia1));
|
|
|
|
std::random_shuffle(ia, ia+sa);
|
|
|
|
assert(std::equal(ia, ia+sa, ia2));
|
2010-05-11 21:42:16 +02:00
|
|
|
}
|