// 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<A> extends WeightlessShuffledIterator<A> { 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<A> list) { this(list, 0); } *(L<A> 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; } }
Began life as a copy of #1035207
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035214 |
Snippet name: | WeightlessShuffledIteratorWithSeed (working backup with external LSFR) |
Eternal ID of this version: | #1035214/1 |
Text MD5: | 8b116a2d0e25f7ee3dc2b59831cc87e9 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-04-15 17:25:19 |
Source code size: | 990 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 204 / 228 |
Referenced in: | [show references] |