1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
void AlgoMMPCbar::subs(const std::vector<unsigned int>& org, const std::vector<unsigned int>& pre, size_t k, size_t n, SubSets& c)
{
if (n <= 1) {
for(size_t i = k; i < org.size(); i++){
std::vector<unsigned int> v(pre);// instead of printing...
v.push_back(org.at(i));
c.push_back(v);
}
} else {
size_t n1 = n - 1;
for(size_t i = k; i != org.size() - n1; i++){ //
std::vector<unsigned int> s(pre);
s.push_back(org.at(i));
subs(org,s,i+1,n1,c);
}
}
}
void AlgoMMPCbar::computeSubSets(const std::vector<unsigned int>& org, size_t& n, SubSets& c){
c.clear(); // clear previous data
std::vector<unsigned int> pre;
pre.reserve(n+1); // for performance
if (n==0)
c.push_back(pre);
else
subs(org,pre,0, n, c);
}
|