numeric
Public Types | Public Member Functions | List of all members
numeric::Permutation< T > Class Template Reference

Create permutation on a list of given types. More...

#include <Combinatorics.hpp>

Public Types

typedef std::vector< T > ItemList
 

Public Member Functions

 Permutation (const std::vector< T > items)
 
bool next ()
 
const ItemListcurrent () const
 
uint64_t numberOfPermutations () const
 

Detailed Description

template<class T>
class numeric::Permutation< T >

Create permutation on a list of given types.

#include <numeric/Combinatorics.hpp>
...
std::string content = "abcd";
std::vector<char> characterList(content.begin(), content.end());

numeric::Permutation<char> permutation(characterList);
do {
    std::vector<char> current = permutation.current();
    std::string s(current.begin(), current.end());
    std::cout << "Current permutation: " << s << std::endl;
} while(permutation.next());

Member Typedef Documentation

◆ ItemList

template<class T >
typedef std::vector<T> numeric::Permutation< T >::ItemList

Constructor & Destructor Documentation

◆ Permutation()

template<class T >
numeric::Permutation< T >::Permutation ( const std::vector< T >  items)
inline

Default constructor for permutation of a given list of items

Parameters
itemsList of items to compute all permutations for

Member Function Documentation

◆ current()

template<class T >
const ItemList& numeric::Permutation< T >::current ( ) const
inline

Retrieve the current permutated list of items

Returns
The permutated items

◆ next()

template<class T >
bool numeric::Permutation< T >::next ( )
inline

Retrieve the next permutation

Returns
True if there is a next permutation, False otherwise

◆ numberOfPermutations()

template<class T >
uint64_t numeric::Permutation< T >::numberOfPermutations ( ) const
inline

Get the total number of permutations

Returns
Number of permutations

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