PermutationGenerator (Groovy 5.0.7)

Package: groovy.util

## [Java] Class PermutationGenerator<E>

- groovy.util.PermutationGenerator

- All Implemented Interfaces and Traits:
    Iterator

      public class PermutationGenerator<E>
      extends Object
      implements Iterator

  Systematically generate permutations. Adapted from Java Code by Michael Gilleland (released with no restrictions) using an algorithm described here: Kenneth H. Rosen, Discrete Mathematics and Its Applications, 2nd edition (NY: McGraw-Hill, 1991), pp. 282-284

- - ### Constructor Summary

    Constructors
    Constructor and description
    `PermutationGenerator(Collection<E> items)` WARNING: Don't make n too large.
    `PermutationGenerator(Iterable<E> items)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public BigInteger` | `getTotal()`
    `` | `public boolean` | `hasNext()`
    `` | `public List<E>` | `next()` Generate next permutation (algorithm from Rosen p. 284)
    `` | `public void` | `remove()`
    `` | `public void` | `reset()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public PermutationGenerator(Collection<E> items)

      WARNING: Don't make n too large. Recall that the number of permutations is n! which can be very large, even when n is as small as 20 -- 20! = 2,432,902,008,176,640,000 and 21! is too big to fit into a Java long, which is why we use BigInteger instead.

      Parameters:
        `items` - the items to permute

    - #### public PermutationGenerator(Iterable<E> items)

  - ### Method Detail

    - #### public BigInteger getTotal()

    - #### @Override
      public boolean hasNext()

    - #### @Override
      public List<E> next()

      Generate next permutation (algorithm from Rosen p. 284)

      Returns:
        the items permuted

    - #### @Override
      public void remove()

    - #### public void reset()