22 [](
size_t m ){ return m == 0; } ) )
52CombinationGenerator::operator bool()
const {
63UniqueCombinationGenerator::operator bool()
const {
97 for (
const auto& gen:
m_generators) { sz += gen.size(); }
116NestedUniqueCombinationGenerator::operator bool()
const {
129 void combMaker(
const Index2DVec& indices,
const std::function<
void (
const Index1DVec&) >& handle,
const std::function<
bool (
const Index1DVec&) >& filter,
size_t rank=0,
Index1DVec combination={} ) {
131 for (
auto position: indices[rank] ) {
133 if ( std::find( combination.begin(), combination.end(), position ) == combination.end() ) {
137 if ( combination.size() == rank ) {
138 combination.push_back( position );
140 combination[rank] = position;
142 if ( combination.size() ==
indices.size() ) {
143 if (
filter( combination ) ){
144 handle( combination );
147 combMaker( indices, handle, filter, rank+1, combination);
156 const auto handle = [&](
const Index1DVec& combination ) {
for (
auto el: combination ) participants.insert(participants.begin(), el); };
157 combMaker( indices, handle, filter );
161 auto handle = [&](
const Index1DVec& combination ) { combinations.push_back( combination ); };
162 combMaker( indices, handle, filter );
std::vector< size_t > m_current
std::vector< size_t > m_maxes
CombinationGenerator(const std::initializer_list< size_t > &collectionSizes)
construct combnations maker with the sizes of collection to which it should be applied
void operator++()
moves to the next combination
std::vector< UniqueCombinationGenerator > m_generators
std::vector< size_t > m_current
void add(const UniqueCombinationGenerator &gen)
Generator of unique combinations (no indices are repeated) API description.
std::vector< bool > m_bitmask
UniqueCombinationGenerator(size_t nelems, size_t comblen)
std::vector< size_t > m_current
bool exists(const std::string &filename)
does a file exist
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, const std::function< bool(const Index1DVec &)> &filter)
std::vector< Index1DVec > Index2DVec
std::vector< size_t > Index1DVec
Unique combinations for case when one can not repeat the index (i.e.
void findUniqueCombinations(const Index2DVec &indices, std::vector< std::vector< size_t > > &combinations, const std::function< bool(const Index1DVec &)> &filter)
Creates unique combinations of elements.
std::pair< long int, long int > indices
void fill(H5::Group &out_file, size_t iterations)