CGAL 6.1.1 - Geometric Object Generators

Loading...
Searching...
No Matches
List of all members
CGAL::Combination_enumerator< CombinationElement > Class Template Reference
Reference Manual

`#include <CGAL/Combination_enumerator.h>`

## Definition

template<class CombinationElement>
class CGAL::Combination_enumerator< CombinationElement >

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

  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.

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)`.
| 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.

## 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.
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.
void | operator++ ()
| Moves *this to the next combination.
Combination_enumerator | operator++ (int)
| Post-incrementation.

## Constructor & Destructor Documentation

## ◆ Combination_enumerator()

template<class CombinationElement >

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.

Precondition
  `1 <= k <= beyond - first`

## Member Function Documentation

## ◆ min_element()

template<class CombinationElement >

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).

## ◆ operator++()

template<class CombinationElement >

Combination_enumerator CGAL::Combination_enumerator< CombinationElement >::operator++ | ( | int |  | ) |

Post-incrementation.

Same as the pre-incrementation above, but returns the original value of `*this`.

## ◆ operator[]()

template<class CombinationElement >

const CombinationElement & CGAL::Combination_enumerator< CombinationElement >::operator[] | ( | int | i | ) |

Returns the `i`-th element of the current combination.

Precondition
  `0 <= i < number_of_elements()`

## ◆ reset()

template<class CombinationElement >

void CGAL::Combination_enumerator< CombinationElement >::reset | ( |  | ) |

Resets the enumerator.

The current combination is set to the first one of the enumeration.