Class Permutator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.String[]>

    final class Permutator
    extends java.lang.Object
    implements java.util.Iterator<java.lang.String[]>
    Iterate over all possible permutations of an array.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String[] array
      The array we are permuting.
      private short[] count
      Counts for Heap's algorithm.
      private boolean nextExists
      Does another permutation exist?.
      private int state
      State for Heap's algorithm.
    • Constructor Summary

      Constructors 
      Constructor Description
      Permutator​(java.lang.String[] input)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      java.lang.String[] next()  
      (package private) void swap​(int i, int j)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Field Detail

      • array

        private final java.lang.String[] array
        The array we are permuting.
      • count

        private final short[] count
        Counts for Heap's algorithm.
      • nextExists

        private boolean nextExists
        Does another permutation exist?.
      • state

        private int state
        State for Heap's algorithm.
    • Constructor Detail

      • Permutator

        Permutator​(java.lang.String[] input)
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.String[]>
      • next

        public java.lang.String[] next()
        Specified by:
        next in interface java.util.Iterator<java.lang.String[]>
      • swap

        void swap​(int i,
                  int j)