Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.0
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.util
Class PermutationGenerator

    java.lang.Object
      groovy.util.PermutationGenerator

All Implemented Interfaces:
  Iterator

    class PermutationGenerator
    extends Object

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
`PermutationGenerator(Collection items)` WARNING: Don't make n too large.

Method Summary
`BigInteger` | `getTotal()`
`boolean` | `hasNext()`
`List` | `next()` Generate next permutation (algorithm from Rosen p. 284)
`void` | `remove()`
`void` | `reset()`

Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Constructor Detail

### PermutationGenerator

    public PermutationGenerator(Collection 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.
  param:
    items the items to permute

Method Detail

### getTotal

    public BigInteger getTotal()

### hasNext

    public boolean hasNext()

### next

    public List next()

  Generate next permutation (algorithm from Rosen p. 284)
  return:
    the items permuted

### remove

    public void remove()

### reset

    public void reset()

Copyright © 2003-2009 The Codehaus. All rights reserved.