Package cc.redberry.combinatorics
Class IntPermutationsWithPriority
- java.lang.Object
-
- cc.redberry.combinatorics.IntPermutationsWithPriority
-
- All Implemented Interfaces:
IntCombinatorialPort,java.io.Serializable
public final class IntPermutationsWithPriority extends java.lang.Object implements IntCombinatorialPort
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 viareset().- Since:
- 1.0
- See Also:
IntPermutations, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classIntPermutationsWithPriority.PermutationPriorityTuple-
Nested classes/interfaces inherited from interface cc.redberry.combinatorics.IntCombinatorialPort
IntCombinatorialPort.Iterator
-
-
Field Summary
Fields Modifier and Type Field Description private IntPermutationsgeneratorprivate int[]lastprivate intlastTuplePointerprivate static longserialVersionUIDprivate java.util.Set<IntPermutationsWithPriority.PermutationPriorityTuple>setprivate java.util.List<IntPermutationsWithPriority.PermutationPriorityTuple>tuples
-
Constructor Summary
Constructors Constructor Description IntPermutationsWithPriority(int dimension)IntPermutationsWithPriority(int[] initialPermutation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]getReference()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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
generator
private final IntPermutations generator
-
tuples
private final java.util.List<IntPermutationsWithPriority.PermutationPriorityTuple> tuples
-
set
private final java.util.Set<IntPermutationsWithPriority.PermutationPriorityTuple> set
-
last
private int[] last
-
lastTuplePointer
private int lastTuplePointer
-
-
Method Detail
-
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)
-
-