combinatorics
Class Permuter<T>

java.lang.Object
  extended by combinatorics.CombinatoricOperator<T>
      extended by combinatorics.Permuter<T>
Type Parameters:
T - The type of the array to be permuted.
All Implemented Interfaces:
java.lang.Iterable<T[]>, java.util.Iterator<T[]>

public final class Permuter<T>
extends CombinatoricOperator<T>

A class that permutes a given array of elements. It is an iterator that returns all permutations, successively. Thanks to Tim Tyler for the original implementation http://mandala.co.uk/permutations/.

Author:
Hendrik Maryns

Field Summary
 
Fields inherited from class combinatorics.CombinatoricOperator
elements, indices
 
Constructor Summary
Permuter(T[] elements)
          Initialise a new permuter, with given array of elements to permute.
 
Method Summary
protected  void computeNext()
          Compute the next array of indices.
protected  double initialiseTotal(int n, int r)
          Compute the total number of elements to return.
 
Methods inherited from class combinatorics.CombinatoricOperator
collectionToArray, factorial, getNumLeft, getTotal, hasNext, initialiseIndices, iterator, next, remove, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Permuter

public Permuter(T[] elements)
Initialise a new permuter, with given array of elements to permute.

Parameters:
elements - The elements to permute.
Method Detail

initialiseTotal

protected double initialiseTotal(int n,
                                 int r)
Compute the total number of elements to return.

Specified by:
initialiseTotal in class CombinatoricOperator<T>
Parameters:
n - The number of elements the operator works on.
r - The size of the arrays to return.
Returns:
The factorial of the number of elements. | result == factorial(n)
See Also:
CombinatoricOperator.initialiseTotal(int, int)

computeNext

protected void computeNext()
Compute the next array of indices.

Specified by:
computeNext in class CombinatoricOperator<T>
See Also:
CombinatoricOperator.computeNext()


Copyright © 2008 This is an undergraduate research project at the University of Kent Computing Laboratory. All Rights Reserved.