cppannotations/yo/stl/randomshuffle.yo
2007-07-25 09:03:21 +00:00

32 lines
1.5 KiB
Text

hi(random_shuffle())
itemization(
it() Header file:
centt(#include <algorithm>)
it() Function prototypes:
itemization(
itt(void random_shuffle(RandomAccessIterator first,
RandomAccessIterator last);)
itt(void random_shuffle+OPENPARRandomAccessIterator first,
RandomAccessIterator last,)linebreak()
tt(RandomNumberGenerator rand+CLOSEPAR;)
)
it() Description:
itemization(
it() The first prototype: the elements in the range rangett(first,
last) are randomly reordered.
it() The second prototype: The elements in the range
rangett(first, last) are randomly reordered using the tt(rand)
i(random number generator), which should return an tt(int) in the range
rangett(0, remaining), where tt(remaining) is passed as argument to the
ti(operator()()) of the tt(rand) function object. Alternatively, the random
number generator may be a function expecting an tt(int remaining) parameter
and returning an tt(int) randomvalue in the range rangett(0, remaining). Note
that when a function object is used, it cannot be an anonymous object. The
function in the example uses a procedure outlined in em(Press et al.) (1992)
hi(Press, W.H.) hi(Numerical Recipes in C) bf(Numerical Recipes in C: The
Art of Scientific Computing) (New York: Cambridge University Press, (2nd ed.,
p. 277)).
)
it() Example:
verbinclude(stl/cc/randomshuffle.cc)
)