Class GCodedPermutations
java.lang.Object
com.glitchybyte.glib.combinatorics.GCodedSequencesGenerator
com.glitchybyte.glib.combinatorics.GCodedPermutations
- All Implemented Interfaces:
Iterable<int[]>
Coded permutations.
A coded sequence generator where the order of items matter. The code itself is a sequence of indexes.
-
Field Summary
Fields inherited from class com.glitchybyte.glib.combinatorics.GCodedSequencesGenerator
allowDuplicateItems, itemCount, maxSize, minSize -
Constructor Summary
ConstructorsConstructorDescriptionGCodedPermutations(int itemCount, boolean allowDuplicateItems) Creates a coded sequence generator of a size equal toitemCount.GCodedPermutations(int itemCount, boolean allowDuplicateItems, int minSize, int maxSize) Creates a coded sequence generator with an iterator with the given characteristics. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanincCode(int[] code) Increases the code one step.Methods inherited from class com.glitchybyte.glib.combinatorics.GCodedSequencesGenerator
iteratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
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-trueif 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 toitemCount.- Parameters:
itemCount- Number of unique items.allowDuplicateItems-trueif 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:
incCodein classGCodedSequencesGenerator- Parameters:
code- Current code.- Returns:
trueif code was increased.
-