Package net.sf.colossus.util
Class PermGen
java.lang.Object
net.sf.colossus.util.PermGen
This class is a permutation generator. The permutations are generated
using Dershowitz's method, meaning that a permutation only differs
by the previous permutation by a single interchange of two adjacent
elements. In many problem domains this allows a efficient dynamic
update of a permutation function.
- Author:
- Peter Unold
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]
get the current permutationint
getNext()
generates the next permutation.static void
Unit test for PermGen.
-
Field Details
-
m_p
int[] m_p -
m_l
int[] m_l -
m_t
int[] m_t -
m_d
int[] m_d -
m_size
int m_size
-
-
Constructor Details
-
PermGen
PermGen(int size)
-
-
Method Details
-
getNext
public int getNext()generates the next permutation. If the function returns n, then the elements at position n and n + 1 in the previous permutation were interchanged to get the new permutation.- Returns:
- the index of the lower element which was interchanged or - 1 if the last permutation has been reached.
-
getCurrent
public int[] getCurrent()get the current permutation -
main
Unit test for PermGen.
-