Function PGAShuffle
Defined in File utility.c
Function Documentation
-
void PGAShuffle(PGAContext *ctx, int *list, int n)
Shuffle a list.
Description
We’re using Durstenfeld’s version of the Fisher-Yates shuffle.
Example
PGAContext *ctx; int list [ctx->ga.PopSize]; ... for (i=0; i<ctx->ga.PopSize; i++) { list [i] = i; } PGAShuffle (ctx, list, ctx->ga.PopSize);
- Parameters:
ctx – Context pointer
list – array of integers to shuffle
n – number of elements in array
- Returns:
Shuffled array