org.expasy.jpl.commons.base.math
Class CombinationFactory

java.lang.Object
  extended by org.expasy.jpl.commons.base.math.CombinationFactory
All Implemented Interfaces:
org.apache.commons.collections15.Transformer<int[],List<int[]>>

public final class CombinationFactory
extends Object
implements org.apache.commons.collections15.Transformer<int[],List<int[]>>

Generate all combinations of p things among n.

Version:
1.0
Author:
nikitin

Constructor Summary
CombinationFactory()
           
 
Method Summary
static long computeCombNumber(int p, int n)
          Compute the number of all the combinations of p elements among n.
static CombinationFactory newInstance()
           
 List<int[]> process(int p, int n)
          Generate all combinations of p elements among n.
static String toString(List<int[]> combinations)
           
 List<int[]> transform(int[] param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombinationFactory

public CombinationFactory()
Method Detail

newInstance

public static CombinationFactory newInstance()

transform

public List<int[]> transform(int[] param)
Specified by:
transform in interface org.apache.commons.collections15.Transformer<int[],List<int[]>>
Throws:
IllegalArgumentException - if invalid parameters.

process

public List<int[]> process(int p,
                           int n)
Generate all combinations of p elements among n.

Parameters:
p - p.
n - n.
Returns:
a list of combinations.
Throws:
IllegalArgumentException - if invalid parameters.

computeCombNumber

public static long computeCombNumber(int p,
                                     int n)
Compute the number of all the combinations of p elements among n.

Parameters:
p - p.
n - n.
Returns:
the total number of C(n, p).

toString

public static String toString(List<int[]> combinations)


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.