LIBINT  2.6.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename > Struct Template Reference

Iterates over all partitions of a non-negative integer $n$ into $k>0$ nonnegative integers in reverse lexicographical order. More...

#include <intpart_iter.h>

Public Types

typedef const Sequence & value_type
 
typedef Sequence::value_type integer_type
 
typedef std::make_unsigned< integer_type >::type unsigned_integer_type
 
typedef Sequence::size_type size_type
 

Public Member Functions

template<typename Seq = Sequence>
 FixedOrderedIntegerPartitionIterator (unsigned_integer_type n, typename std::enable_if< detail::has_static_size< Seq >::value >::type *=nullptr)
 
 FixedOrderedIntegerPartitionIterator (unsigned_integer_type n, size_type k)
 
intmax_t range_size () const
 
value_type operator* () const
 
const Sequence * operator-> () const
 
 operator bool () const
 
bool last () const
 
void next ()
 update to the next partition in the range More...
 

Static Public Member Functions

template<typename Seq >
static intmax_t rank (const Seq &part)
 returns the rank (index) of partition part in the partition range
 

Detailed Description

template<typename Sequence, typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
struct libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >

Iterates over all partitions of a non-negative integer $n$ into $k>0$ nonnegative integers in reverse lexicographical order.

E.g. partitions of $n=2$ into sets of $k=3$ integers appear in this order: {2 0 0}, {1 1 0}, {1 0 1}, {0 2 0}, {0 1 1}, and {0 0 2}.

Template Parameters
Sequenceinteger sequence with dense storage (std::vector, std::array, and built-in array will work)

Constructor & Destructor Documentation

◆ FixedOrderedIntegerPartitionIterator() [1/2]

template<typename Sequence , typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
template<typename Seq = Sequence>
libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::FixedOrderedIntegerPartitionIterator ( unsigned_integer_type  n,
typename std::enable_if< detail::has_static_size< Seq >::value >::type *  = nullptr 
)
inlineexplicit
Parameters
nthe positive integer to be partitioned
kthe number of partitions, 1 or greater

◆ FixedOrderedIntegerPartitionIterator() [2/2]

template<typename Sequence , typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::FixedOrderedIntegerPartitionIterator ( unsigned_integer_type  n,
size_type  k 
)
inline
Parameters
nthe positive integer to be partitioned
kthe number of partitions, 1 or greater

Member Function Documentation

◆ last()

template<typename Sequence , typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
bool libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::last ( ) const
inline

◆ next()

template<typename Sequence , typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
void libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::next ( )
inline

◆ operator bool()

template<typename Sequence , typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::operator bool ( ) const
inline
Returns
true if operator* returns the last partition in the range

References libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::last().

◆ range_size()

template<typename Sequence , typename = typename std::enable_if<std::numeric_limits< typename Sequence::value_type>::is_integer>::type>
intmax_t libint2::FixedOrderedIntegerPartitionIterator< Sequence, typename >::range_size ( ) const
inline
Returns
the number of unique partitions

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