combos.hpp

Tools to step through combinations of items.

Step through all combinations of size K from a set of N values. For ComboIDs just return the indecies (the specific of the container don’t matter). Other versions will directly wrapper containers.

Todo:

Allow a minimum and maximum combo size, not just a fixed combo size. If no sizes are specifed, all sizes should be explored (all possible combinations).

Create a ComboGenerator template to take a container and generate all combinations

Create a combos function that will build a ComboGenerator for the container type passed in.

class ComboIDs
#include <combos.hpp>

Public Functions

ComboIDs(size_t in_max, size_t combo_size)
inline ~ComboIDs()
inline const vector<size_t> &GetCombo() const
inline const vector<size_t> &GetMaxCombo() const
inline size_t GetComboSize() const
inline size_t GetNumCombos() const
inline size_t &operator[](const size_t index)
inline const size_t &operator[](const size_t index) const
const vector<size_t> &Reset()
bool NextCombo()
void ResizeCombos(size_t new_size)
vector<size_t> GetInverseCombo()
inline ComboIDs &operator++()
inline ComboIDs &operator++(int)
inline size_t size()

Private Members

size_t max_count
vector<size_t> cur_combo
vector<size_t> max_combo
size_t num_combos

Private Static Functions

static size_t CountCombos(size_t max_count, size_t combo_size)