Class GCodedPermutations

java.lang.Object
com.glitchybyte.glib.combinatorics.GCodedSequencesGenerator
com.glitchybyte.glib.combinatorics.GCodedPermutations
All Implemented Interfaces:
Iterable<int[]>

public final class GCodedPermutations extends GCodedSequencesGenerator
Coded permutations.

A coded sequence generator where the order of items matter. The code itself is a sequence of indexes.

  • Constructor Details

    • GCodedPermutations

      public GCodedPermutations(int itemCount, boolean allowDuplicateItems, int minSize, int maxSize)
      Creates a coded sequence generator with an iterator with the given characteristics.
      Parameters:
      itemCount - Number of unique items.
      allowDuplicateItems - true if a sequence can use the same item more than once.
      minSize - Minimum size of a sequence.
      maxSize - Maximum size of a sequence.
    • GCodedPermutations

      public GCodedPermutations(int itemCount, boolean allowDuplicateItems)
      Creates a coded sequence generator of a size equal to itemCount.
      Parameters:
      itemCount - Number of unique items.
      allowDuplicateItems - true if a sequence can use the same item more than once.
  • Method Details

    • incCode

      protected boolean incCode(int[] code)
      Increases the code one step.
      Specified by:
      incCode in class GCodedSequencesGenerator
      Parameters:
      code - Current code.
      Returns:
      true if code was increased.