Class Combination

Class Documentation

class bitbots_splines::Combination

Combination

Implement binomial coefficient computation using Pascal Triangle and iterate thought all (n choose k) combinations

Public Functions

unsigned long binomialCoefficient(size_t k, size_t n)

Compute the number of possible combinations for (n choose k) (using dynamic progamming)

void startCombination(size_t k, size_t n)

Start combination iteration for given (n choose k)

std::vector<size_t> nextCombination()

Return the next combination. Return empty sdt::vector when iteration is finished

Private Types

typedef std::pair<unsigned long, unsigned long> Pair

Typedefs

typedef std::vector<size_t> Comb

Private Functions

bool incrIndexes(size_t i)

Increment by one the _indexes container at digit i (recursively). Return true on iteration end

Private Members

std::map<Pair, unsigned long> pascal_triangle_

Hold (n choose k) number of possible combinations for dynamic programming

std::vector<size_t> indexes_

Current indexes container and iteration n and k parameter

size_t n_ = 0
size_t k_ = 0