cc.redberry.core.combinatorics
Class Combinatorics
- java.lang.Object
-
- cc.redberry.core.combinatorics.Combinatorics
-
public final class Combinatorics extends java.lang.ObjectThis class provides factory and utility methods for combinatorics infrastructure.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static IntCombinatorialGeneratorcreateIntGenerator(int n, int k)Returns anIntCombinatorialGeneratorobject, which allows to iterate over all possible unique combinations with permutations (i.e.
-
-
-
Method Detail
-
createIntGenerator
public static IntCombinatorialGenerator createIntGenerator(int n, int k)
Returns an
IntCombinatorialGeneratorobject, which allows to iterate over all possible unique combinations with permutations (i.e. {0,1} and {1,0} both appears fork=2) ofknumbers, which can be chosen from the set ofnnumbers, numbered in the order 0,1,2,...,n. The total number of such combinations will ben!/(n-k)!.For example, for
k=2andn=3, this method will produce an iterator over the following arrays: [0,1], [1,0], [0,2], [2,0], [1,2], [2,1].- Parameters:
n- number of elements in the setk- sample size- Returns:
- an iterator over all combinations (with permutations) to choose k numbers from n numbers.
- See Also:
IntCombinatorialGenerator
-
-
DataMelt 3.0 © DataMelt by jWork.ORG