// Allows to vary the order by supplying a seed // // We add the seed to every LSFR value generated, and also start // the LSFR with the seed. sclass WeightlessShuffledIteratorWithSeed extends WeightlessShuffledIterator { final int cycleLength, offset; // initialize only with a length (and a pseudo-list) // if you are going to be calling nextIndex() instead of next() *(int n) { this((L) virtualNullList(n)); } *(int n, int seed) { this((L) virtualNullList(n), seed); } *(L list) { this(list, 0); } *(L list, int seed) { super(list); if (lsfr == null) { cycleLength = offset = 0; ret; } lsfr.start(seed); cycleLength = lsfr.cycleLength(); offset = lsfr.value-1; printVars ifdef WeightlessShuffledIterator_debug(+seed, +cycleLength, +offset, start := lsfr.value); } int postProcessLSFRValue(int i) { i += offset; ret i >= cycleLength ? i-cycleLength : i; } }