\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 4.6.3 - Geometric Object Generators
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
CGAL::Combination_enumerator< CombinationElement > Class Template Reference

#include <CGAL/Combination_enumerator.h>

Definition

The class Combination_enumerator is used to enumerate all fixed-size combinations (subsets) of a source range of elements.

For example, it can enumerate all the combinations of 2 elements from the source range [3,7) (7 excluded) which gives the enumeration {3,4}, {3,5}, {3,6}, {4,5}, {4,6}, {5,6}. The source range consists of elements of type CombinationElement and is specified by its first element and the element just beyond its last one.

Template Parameters
CombinationElementshould be a model of the concept CombinationElement.

Each combination is uniquely represented as an increasing sequence of elements. Thus, the combinations can be lexicographically ordered. They are enumerated in that order, so that we can talk about the first or last combination.

Examples:
Generator/combination_enumerator.cpp, and Generator/name_pairs.cpp.

Creation

 Combination_enumerator (int k, const CombinationElement &first, const CombinationElement &beyond)
 This constructor initializes the object to enumerate the combinations of k elements from the source range [first, beyond). More...
 
 Combination_enumerator (const Combination_enumerator &combi)
 The copy constructor.
 

Access to the Current Combination

const CombinationElementoperator[] (int i)
 Returns the i-th element of the current combination. More...
 

Access to the Enumeration

int number_of_elements ()
 Returns the size of the enumerated combinations (the parameter k from the class' constructor).
 
const CombinationElementmin_element ()
 Returns the smallest element of the source range. More...
 
const CombinationElementbeyond_element ()
 Returns the successor to the largest element of the source range (the parameter beyond of the constructor of the class).
 
bool finished ()
 Returns true if and only if all combinations have been enumerated.
 

Operations

void reset ()
 Resets the enumerator. More...
 
void operator++ ()
 Moves *this to the next combination.
 
Combination_enumerator operator++ (int)
 Post-incrementation. More...