CMR  1.3.0
Public Types | Public Member Functions | Protected Member Functions | List of all members
tu::permutation_enumerator Class Referenceabstract

#include <permutations.hpp>

Public Types

typedef size_t size_type
 
typedef std::vector< permutation::value_typememberlist_type
 
typedef std::pair< memberlist_type *, permutation * > groupinfo_type
 
typedef std::map< int, groupinfo_typestate_type
 

Public Member Functions

 permutation_enumerator (permutation::size_type size)
 
 permutation_enumerator (const std::vector< permutation::value_type > &groups)
 
virtual ~permutation_enumerator ()
 
bool empty ()
 
virtual bool enumerate ()
 

Protected Member Functions

virtual bool visitor (const permutation &perm)=0
 

Detailed Description

Enumerates all permutations of a given size with optional constraints. You must derive from it and override the visitor() method.

Member Typedef Documentation

◆ groupinfo_type

◆ memberlist_type

◆ size_type

◆ state_type

Constructor & Destructor Documentation

◆ permutation_enumerator() [1/2]

tu::permutation_enumerator::permutation_enumerator ( permutation::size_type  size)
inline

Constructs an enumerator without constraints. Has O(size!) running time.

Parameters
sizeSize of the permutations

◆ permutation_enumerator() [2/2]

tu::permutation_enumerator::permutation_enumerator ( const std::vector< permutation::value_type > &  groups)
inline

Constructs an enumerator with grouping constraints: Only those permutations are enumerated where k and p(k) are in the same group for all i.

Parameters
groupsVector of groups

◆ ~permutation_enumerator()

virtual tu::permutation_enumerator::~permutation_enumerator ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ empty()

bool tu::permutation_enumerator::empty ( )
inline
Returns
true if and only if the size of each permutation is zero

◆ enumerate()

virtual bool tu::permutation_enumerator::enumerate ( )
inlinevirtual

Starts the enumeration which is aborted if any visitor returns false.

Returns
true if and only if all visitors returned true

◆ visitor()

virtual bool tu::permutation_enumerator::visitor ( const permutation perm)
protectedpure virtual

Method which is called for each enumerated permutation. Needs to be overridden.

Parameters
permCurrent permutation
Returns
false to abort enumeration

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