Class GroupedPermutationGenerator.Builder

java.lang.Object
io.bloviate.gen.AbstractBuilder<Integer>
io.bloviate.gen.GroupedPermutationGenerator.Builder
All Implemented Interfaces:
Builder<Integer>
Enclosing class:
GroupedPermutationGenerator

public static class GroupedPermutationGenerator.Builder extends AbstractBuilder<Integer>
  • Constructor Details

    • Builder

      public Builder(RandomGenerator random)
      Creates a builder.
      Parameters:
      random - the random source (unused by this generator, but required by the contract)
  • Method Details

    • groupSize

      public GroupedPermutationGenerator.Builder 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. It is the groupSize divisor in start + permute(rowIndex % groupSize) keyed by rowIndex / groupSize. Must be in [1, 2^30], otherwise build() throws. Defaults to 1.
      Parameters:
      groupSize - the number of rows per permutation block; must be in [1, 2^30]
      Returns:
      this builder, for chaining
    • start

      public GroupedPermutationGenerator.Builder start(int start)
      The lowest value of the permuted range, inclusive: each group is a permutation of [start, start + groupSize) (the start offset added to each permuted index). Defaults to 0.
      Parameters:
      start - the lowest value of the permuted range, inclusive
      Returns:
      this builder, for chaining
    • seed

      public GroupedPermutationGenerator.Builder seed(long 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 to 0.
      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 - if groupSize is not in [1, 2^30]