CGAL 5.1.2 - Geometric Object Generators
|
#include <CGAL/Combination_enumerator.h>
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.
CombinationElement | should 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.
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 CombinationElement & | operator[] (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 CombinationElement & | min_element () |
Returns the smallest element of the source range. More... | |
const CombinationElement & | beyond_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... | |
CGAL::Combination_enumerator< CombinationElement >::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)
.
The current combination is set to the first combination of the enumeration.
1 <= k <= beyond - first
const CombinationElement& CGAL::Combination_enumerator< CombinationElement >::min_element | ( | ) |
Returns the smallest element of the source range.
(the parameter first
of the constructor of the class).
Combination_enumerator CGAL::Combination_enumerator< CombinationElement >::operator++ | ( | int | ) |
Post-incrementation.
Same as the pre-incrementation above, but returns the original value of *this
.
const CombinationElement& CGAL::Combination_enumerator< CombinationElement >::operator[] | ( | int | i | ) |
Returns the i
-th element of the current combination.
0 <= i < number_of_elements()
void CGAL::Combination_enumerator< CombinationElement >::reset | ( | ) |
Resets the enumerator.
The current combination is set to the first one of the enumeration.