Class PermGen

java.lang.Object
net.sf.colossus.util.PermGen

class PermGen extends Object
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
    Modifier and Type
    Field
    Description
    (package private) int[]
     
    (package private) int[]
     
    (package private) int[]
     
    (package private) int
     
    (package private) int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PermGen(int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    get the current permutation
    int
    generates the next permutation.
    static void
    main(String[] args)
    Unit test for PermGen.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static void main(String[] args)
      Unit test for PermGen.