numeric
Public Member Functions | Static Public Member Functions | List of all members
numeric::LimitedCombination< AtomType > Class Template Reference

Compute combinatorics on a given set of limited but typed resources, e.g. for available resource A:2, B:1, C:1 the following combinations are possible: max size 1: A,B,C max size 2: AA, AB, AC, BC max size 3: AAB, AAC, ABC. More...

#include <LimitedCombination.hpp>

Public Member Functions

 LimitedCombination (const AtomType2CountMap &countMap, size_t size, numeric::Mode mode)
 
std::vector< AtomType > current () const
 
size_t getCombinationSize (const std::vector< CoreType > &combination) const
 
bool next ()
 

Static Public Member Functions

static size_t totalNumberOfAtoms (const AtomType2CountMap &countMap)
 

Detailed Description

template<typename AtomType>
class numeric::LimitedCombination< AtomType >

Compute combinatorics on a given set of limited but typed resources, e.g. for available resource A:2, B:1, C:1 the following combinations are possible: max size 1: A,B,C max size 2: AA, AB, AC, BC max size 3: AAB, AAC, ABC.

Use integers to compute the core combinatorics, i.e. avoiding the computational effort for comparison of custom objects

using namespace numeric;
std::map<std::string, size_t> items;
items["A"] = 2;
items["B"] = 1;
items["C"] = 1;

LimitedCombination<std::string> combinations(items, LimitedCombination<std::string>::totalNumberOfAtoms(items), MAX);
do {
   std::vector<std::string> currentCombination = combinations.current();
} while(combinations.next());

Constructor & Destructor Documentation

◆ LimitedCombination()

template<typename AtomType >
numeric::LimitedCombination< AtomType >::LimitedCombination ( const AtomType2CountMap &  countMap,
size_t  size,
numeric::Mode  mode 
)
inline

Construct limited combination generator

Parameters
countMapMapping a item (type) to the maximum possible number of occurence
sizeIn combination with mode, define the combination size
modeInterpretation of the combination size, i.e. can be exact, min or max

Member Function Documentation

◆ current()

template<typename AtomType >
std::vector<AtomType> numeric::LimitedCombination< AtomType >::current ( ) const
inline

Get the current custom combination

Returns
current custom combination

◆ getCombinationSize()

template<typename AtomType >
size_t numeric::LimitedCombination< AtomType >::getCombinationSize ( const std::vector< CoreType > &  combination) const
inline

◆ next()

template<typename AtomType >
bool numeric::LimitedCombination< AtomType >::next ( )
inline

Check if there is a next combination and forward internal iterator, so that current() allows to retrieve this combination

Returns
true if there is another valid combination

◆ totalNumberOfAtoms()

template<typename AtomType >
static size_t numeric::LimitedCombination< AtomType >::totalNumberOfAtoms ( const AtomType2CountMap &  countMap)
inlinestatic

Get the totalNumberOfAtoms, i.e. the sum of occurrence

Returns
total number of atoms defined by the given map

The documentation for this class was generated from the following file: