Package cc.redberry.combinatorics
Class IntPermutationsWithPriority
java.lang.Object
cc.redberry.combinatorics.IntPermutationsWithPriority
- All Implemented Interfaces:
IntCombinatorialPort,Serializable
Iterator over all possible permutations of specified that allows to adjust the "niceness" of particular permutations,
such they will appear earlier in the iteration if iterator was reset via
reset().- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classNested classes/interfaces inherited from interface cc.redberry.combinatorics.IntCombinatorialPort
IntCombinatorialPort.Iterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IntPermutationsprivate int[]private intprivate static final longprivate final Set<IntPermutationsWithPriority.PermutationPriorityTuple>private final List<IntPermutationsWithPriority.PermutationPriorityTuple> -
Constructor Summary
ConstructorsConstructorDescriptionIntPermutationsWithPriority(int dimension) IntPermutationsWithPriority(int[] initialPermutation) -
Method Summary
Modifier and TypeMethodDescriptionint[]Returns the reference to the current iteration elementvoidnice()Increase niceness of the last returned permutation.voidreset()Resets the iterationprivate voidswap(int i, int j) int[]take()Calculates and returns the next combination or null, if no more combinations exist.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
generator
-
tuples
-
set
-
last
private int[] last -
lastTuplePointer
private int lastTuplePointer
-
-
Constructor Details
-
IntPermutationsWithPriority
public IntPermutationsWithPriority(int dimension) -
IntPermutationsWithPriority
public IntPermutationsWithPriority(int[] initialPermutation)
-
-
Method Details
-
take
public int[] take()Description copied from interface:IntCombinatorialPortCalculates and returns the next combination or null, if no more combinations exist.- Specified by:
takein interfaceIntCombinatorialPort- Returns:
- the next combination or null, if no more combinations exist
-
nice
public void nice()Increase niceness of the last returned permutation. -
reset
public void reset()Description copied from interface:IntCombinatorialPortResets the iteration- Specified by:
resetin interfaceIntCombinatorialPort
-
getReference
public int[] getReference()Description copied from interface:IntCombinatorialPortReturns the reference to the current iteration element- Specified by:
getReferencein interfaceIntCombinatorialPort- Returns:
- the reference to the current iteration element
-
swap
private void swap(int i, int j)
-