combos.hpp

Tools to step through combinations of items.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2017-2024 Michigan State University MIT Software license; see doc/LICENSE.md

Step through all combinations of size k from a set of N values. For ComboIDs just return the indices (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 specified, 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.

Defines

INCLUDE_EMP_MATH_COMBOS_HPP_GUARD
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 constexpr size_t CountCombos(size_t max_count, size_t combo_size)