Class GroupedPermutationGenerator.Builder
- Enclosing class:
GroupedPermutationGenerator
Builder for
GroupedPermutationGenerator.-
Field Summary
Fields inherited from class AbstractBuilder
DEFAULT_REFERENCE, random -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the generator.groupSize(int groupSize) The size of each permutation group: every consecutive run of this many rows is an independent shuffle (a within-group permutation) of[start, start + groupSize), after which a fresh permutation begins.seed(long seed) Salt for the per-group permutation key.start(int start) The lowest value of the permuted range, inclusive: each group is a permutation of[start, start + groupSize)(thestartoffset added to each permuted index).
-
Constructor Details
-
Builder
Creates a builder.- Parameters:
random- the random source (unused by this generator, but required by the contract)
-
-
Method Details
-
groupSize
The size of each permutation group: every consecutive run of this many rows is an independent shuffle (a within-group permutation) of[start, start + groupSize), after which a fresh permutation begins. It is thegroupSizedivisor instart + permute(rowIndex % groupSize)keyed byrowIndex / groupSize. Must be in[1, 2^30], otherwisebuild()throws. Defaults to1.- Parameters:
groupSize- the number of rows per permutation block; must be in[1, 2^30]- Returns:
- this builder, for chaining
-
start
The lowest value of the permuted range, inclusive: each group is a permutation of[start, start + groupSize)(thestartoffset added to each permuted index). Defaults to0.- Parameters:
start- the lowest value of the permuted range, inclusive- Returns:
- this builder, for chaining
-
seed
Salt for the per-group permutation key. The key for each group is derived deterministically from this seed and the group index, so a fixed seed yields a fully reproducible shuffle for every group (independent of the injected random source). Change it to obtain a different but equally reproducible set of per-group orderings. Defaults to0.- Parameters:
seed- the salt mixed with the group index to key each within-group permutation- Returns:
- this builder, for chaining
-
build
Builds the generator.- Returns:
- a new
GroupedPermutationGenerator - Throws:
IllegalArgumentException- ifgroupSizeis not in[1, 2^30]
-