Class CombinationResolver


  • public final class CombinationResolver
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.util.List<java.lang.Integer>> getAllCombinations​(java.util.List<java.lang.Integer> possibleNumbers, int combinationSize)
      Gets all possible combinations from the given list of Integer objects
      static long getAllPossibleCombinationsCount​(int possibleNumbers, int combinationSize)
      Gets the count of all possible combinations from the given size of the set of possible numbers and the given size of the subset to be counted.
      static <T> java.util.List<java.util.List<T>> getCombinations​(java.util.List<T> possibleValues, int combinationSize)
      Gets all possible combinations from the given list
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CombinationResolver

        public CombinationResolver()
    • Method Detail

      • getAllCombinations

        public static java.util.List<java.util.List<java.lang.Integer>> getAllCombinations​(java.util.List<java.lang.Integer> possibleNumbers,
                                                                                           int combinationSize)
        Gets all possible combinations from the given list of Integer objects
        Parameters:
        possibleNumbers - the possible numbers
        combinationSize - the size of the combination to generate
        Returns:
        all possible combinations from the given list of Integer objects
      • getAllPossibleCombinationsCount

        public static long getAllPossibleCombinationsCount​(int possibleNumbers,
                                                           int combinationSize)
        Gets the count of all possible combinations from the given size of the set of possible numbers and the given size of the subset to be counted. Note:

        uses internally the method of org.apache.commons.math3.util.CombinatoricsUtils#binomialCoefficient(int, int)
        Parameters:
        possibleNumbers - the size of possible numbers
        combinationSize - the size of a single combination
        Returns:
        an exact representation of the Binomial Coefficient, "n choose k", the number of k-element subsets that can be selected from an n-element set.
      • getCombinations

        public static <T> java.util.List<java.util.List<T>> getCombinations​(java.util.List<T> possibleValues,
                                                                            int combinationSize)
        Gets all possible combinations from the given list
        Type Parameters:
        T - the generic type of the elements in the list
        Parameters:
        combinationSize - the size of the elements of the combinations to generate
        possibleValues - the list with the element values
        Returns:
        all possible combinations from the given list