Mackey  V3.3
A C++ library for computing RO(G) graded homology
CombinationGenerator< T > Class Template Reference

Generates all combinations on a number of letters making a number of choices. More...

#include <Generators.hpp>

Classes

class  ConstIterator
 Constant iterator that is used in a ranged for loop to generate the combinations. More...
 

Public Member Functions

auto size () const
 Computes total number of combinations. More...
 
 CombinationGenerator (T total, T choices)
 Sets up the generator. More...
 
ConstIterator begin () const
 Begin iterator. More...
 
ConstIterator end () const
 End iterator. More...
 

Detailed Description

template<class T>
class mackey::CombinationGenerator< T >

Generates all combinations on a number of letters making a number of choices.

Use with a ranged for loop: If v is a CombinationGenerator object then in

for (const auto& i:v) {...}

the variable i will range over all combinations.

Warning
Not thread safe!
Todo:
Implement via coroutine (C++20)
Template Parameters
TThe data type of our combinations eg int

Constructor & Destructor Documentation

◆ CombinationGenerator()

CombinationGenerator ( total,
choices 
)

Sets up the generator.

Parameters
totalThe number of letters
choicesThe number of choices

Member Function Documentation

◆ size()

auto size ( ) const

Computes total number of combinations.

Returns
Binomial \({n}\choose{k}\) where \(n\)=total and \(k\)=choices

◆ begin()

ConstIterator begin ( ) const

Begin iterator.

Returns
An iterator to the first generated element

◆ end()

ConstIterator end ( ) const

End iterator.

Returns
An iterator to the end of the generator (equality with this indicates that the generator has completed)

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