crn
Class PermutationGenerator

java.lang.Object
  extended bycrn.PermutationGenerator

public class PermutationGenerator
extends java.lang.Object

Systematically generate permutations.

Author:
http://www.merriampark.com/perm.htm

Field Summary
private  int[] a
           
private  java.math.BigInteger numLeft
           
private  java.math.BigInteger total
           
 
Constructor Summary
PermutationGenerator(int n)
           
 
Method Summary
private static java.math.BigInteger getFactorial(int n)
           
 int[] getNext()
           
 java.math.BigInteger getNumLeft()
           
 java.math.BigInteger getTotal()
           
 boolean hasMore()
           
 void reset()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

private int[] a

numLeft

private java.math.BigInteger numLeft

total

private java.math.BigInteger total
Constructor Detail

PermutationGenerator

public PermutationGenerator(int n)
Parameters:
n -
Method Detail

reset

public void reset()

getNumLeft

public java.math.BigInteger getNumLeft()
Returns:
Gets the number of left possibilities.

getTotal

public java.math.BigInteger getTotal()
Returns:
Gets the total number of possibilities.

hasMore

public boolean hasMore()
Returns:
A boolean value indicating if there are some more permutations to be visited.

getFactorial

private static java.math.BigInteger getFactorial(int n)
Parameters:
n -
Returns:
Gets the factorial of the given number.

getNext

public int[] getNext()
Returns:
Gets an array being the next permutation.