Class EnumerationOfPermutations

  • All Implemented Interfaces:
    Iterator<int[]>

    public class EnumerationOfPermutations
    extends EnumerationAbstract
    This class allows us to iterate over all permutations of a given set of integer values. See the Johnson-Trotter algorithm (H. F. Trotter[1962], S. M. Johnson[1963]). Execute the main method for an illustration.
    • Constructor Detail

      • EnumerationOfPermutations

        public EnumerationOfPermutations​(int... values)
        Builds an object that can be used for enumerating permutations, using the specified array of values.
        Parameters:
        values - the values used to form permutations
      • EnumerationOfPermutations

        public EnumerationOfPermutations​(int nValues)
        Builds an object that can be used for enumerating permutations, using the specified number of values. All values are taken in the range 0 to nValues-1.
        Parameters:
        nValues - the number of values used to form permutations
    • Method Detail

      • valAt

        protected int valAt​(int i)
        Description copied from class: EnumerationAbstract
        Returns the value of the current tuple at the specified position.
        Specified by:
        valAt in class EnumerationAbstract
        Parameters:
        i - the position of an integer in the tuple
        Returns:
        the value of the current tuple at the specified position
      • main

        public static void main​(String[] args)