cds
2.3.2
|
Permutation generator of power-of-2 length based on rand()
More...
#include <cds/opt/permutation.h>
Public Types | |
typedef Int | integer_type |
Type of generated value. | |
Public Member Functions | |
random2_permutation (size_t nLength) | |
Initializes the generator of length nLength . More... | |
operator integer_type () const | |
Returns the current value. | |
bool | next () |
Goes to next value. Returns false if the sequence is exhausted. | |
void | reset () |
Resets the generator to produce new sequence. | |
Permutation generator of power-of-2 length based on rand()
The class is suitable for opt::permutation_generator
option.
The generator calculates n = rand()
and produces the sequence [n % nLen, (n + 1) % nLen, ..., (n + nLen - 1) % nLen]
. The generator does not allocate any memory. nLen
must be power of two.
Int
template argument specifies the type of generated value, it should be any integer.
|
inline |
Initializes the generator of length nLength
.
An assertion is raised if nLength
is not a power of two.