Package groovy.util
Class PermutationGenerator<E>
- java.lang.Object
- 
- groovy.util.PermutationGenerator<E>
 
- 
- All Implemented Interfaces:
- java.util.Iterator<java.util.List<E>>
 
 public class PermutationGenerator<E> extends java.lang.Object implements java.util.Iterator<java.util.List<E>>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 SummaryConstructors Constructor Description PermutationGenerator(java.lang.Iterable<E> items)PermutationGenerator(java.util.Collection<E> items)WARNING: Don't make n too large.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigIntegergetTotal()booleanhasNext()java.util.List<E>next()Generate next permutation (algorithm from Rosen p.voidremove()voidreset()
 
- 
- 
- 
Constructor Detail- 
PermutationGeneratorpublic PermutationGenerator(java.util.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
 
 - 
PermutationGeneratorpublic PermutationGenerator(java.lang.Iterable<E> items) 
 
- 
 - 
Method Detail- 
resetpublic void reset() 
 - 
getTotalpublic java.math.BigInteger getTotal() 
 - 
hasNextpublic boolean hasNext() - Specified by:
- hasNextin interface- java.util.Iterator<E>
 
 - 
nextpublic java.util.List<E> next() Generate next permutation (algorithm from Rosen p. 284)- Specified by:
- nextin interface- java.util.Iterator<E>
- Returns:
- the items permuted
 
 - 
removepublic void remove() - Specified by:
- removein interface- java.util.Iterator<E>
 
 
- 
 
-