|
|
template <class T> void shuffle(T* b,T* e); template <class T> void shuffle_c(const T* b1,const T* e1,T* b2);
(1) For the copy version, the output array and the input array do not overlap.
(2) For the copy version, the output array has at least as many cells as the input array.
(S) T has operator=.
These functions shuffle (i.e., randomly permute) an array in place.
template <class T> void shuffle(T* b,T* e);
Performs an in-place shuffle.
template <class T> void shuffle_c(const T* b1,const T* e1,T* b2);
Like shuffle except that the input array is preserved and the result written to a new array beginning at location b2.
If N is the size of the array, then complexity is O(N). Exactly 3(N-1) assignments are done.
These functions use drand48(3C) to obtain pseudo-random numbers.
Because a Block (see Block(3C++)) can always be used wherever an array is called for, Array Algorithms can also be used with Blocks. In fact, these two components were actually designed to be used together.