|
cds
2.3.2
|
Permutation generator of arbitrary length based on rand()
More...
#include <cds/opt/permutation.h>
Public Types | |
| typedef Int | integer_type |
| Type of generated value. | |
Public Member Functions | |
| random_permutation (size_t nLength) | |
Initializes the generator of arbitrary length nLength. | |
| operator integer_type () const | |
| Returns the curent 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 arbitrary 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.
Int template argument specifies the type of generated value, it should be any integer.