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

Generates all permutations on a number of letters. More...

#include <Generators.hpp>

Classes

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

Public Member Functions

size_t size () const
 Computes total number of permutations. More...
 
 PermutationGenerator (T n)
 Constructor sets up the generator. More...
 
ConstIterator begin () const
 Begin iterator. More...
 
ConstIterator end () const
 End iterator. More...
 

Detailed Description

template<class T>
class mackey::PermutationGenerator< T >

Generates all permutations on a number of letters.

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

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

the variable i will range over all permutations.

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

Constructor & Destructor Documentation

◆ PermutationGenerator()

Constructor sets up the generator.

Parameters
nThe total number of letters

Member Function Documentation

◆ size()

size_t size ( ) const

Computes total number of permutations.

Returns
Factorial \(n!\) where \(n\) is the number of letters

◆ 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: