CGAL 5.0 - Handles and Circulators

## Macros

#define CGAL_For_all(i, j)
In order to write algorithms that work with iterator ranges as well as with circulator ranges we have to consider the difference of representing an empty range. More...

#define CGAL_For_all_backwards(i, j)
See CGAL_For_all.

## Functions

template<class C >
C::difference_type CGAL::circulator_distance (C c, C d)
The distance of a circulator c to a circulator d is the number of elements in the range [c, d). More...

template<class C >
C::size_type CGAL::circulator_size (C c)
The size of a circulator is the size of the data structure it refers to. More...

template<class IC >
bool CGAL::is_empty_range (const IC &i, const IC &j)
is true if the range [i, j) is empty, false otherwise. More...

template<class IC >
iterator_traits< IC >::difference_type CGAL::iterator_distance (IC ic1, IC ic2)
The following function returns the distance between either two iterators or two circulators. More...

template<class I >
Iterator_tag CGAL::query_circulator_or_iterator (const I &i)
This function matches for type I if the iterator category of I belongs to an iterator. More...

template<class C >
Circulator_tag CGAL::query_circulator_or_iterator (const C &c)
This functiona matches for type C if the iterator category of C belongs to a circulator. More...

## ◆ CGAL_For_all

 #define CGAL_For_all ( i, j )

#include <CGAL/circulator.h>

In order to write algorithms that work with iterator ranges as well as with circulator ranges we have to consider the difference of representing an empty range.

For iterators this is the range [i,i), while for circulators it would be c == nullptr, the empty sequence test. The function is_empty_range() provides the necessary generic test which accepts an iterator range or a circulator range and says whether the range is empty or not.

A macro CGAL_For_all( i, j) simplifies the writing of such simple loops as the one in the example of the function is_empty_range(). i and j can be either iterators or circulators. The macro loops through the range [i, j). It increments i until it reaches j. The implementation looks like:

for ( bool _circ_loop_flag = ! ::CGAL::is_empty_range(i,j);
_circ_loop_flag;
_circ_loop_flag = ((++i) != (j))
)

Note that the macro behaves like a for-loop. It can be used with a single statement or with a statement block. For bidirectional iterators or circulators, a backwards loop macro CGAL_For_all_backwards(i, j) exists that decrements j until it reaches i.

CGAL::iterator_distance()
CGAL::is_empty_range()
CGAL::Circulator_tag
CGAL::Circulator_traits
CGAL::Assert_circulator_or_iterator
Circulator

## ◆ circulator_distance()

template<class C >
 C::difference_type CGAL::circulator_distance ( C c, C d )

#include <CGAL/circulator.h>

The distance of a circulator c to a circulator d is the number of elements in the range [c, d).

It is defined to be zero for a circulator on an empty sequence and it returns the size of the data structure when applied to a range of the form [c, c).

circulator_size
iterator_distance
is_empty_range
Circulator

## ◆ circulator_size()

template<class C >
 C::size_type CGAL::circulator_size ( C c )

#include <CGAL/circulator.h>

The size of a circulator is the size of the data structure it refers to.

It is zero for a circulator on an empty sequence. The size can be computed in linear time for forward and bidirectional circulators, and in constant time for random access circulators using the minimal circulator. The function circulator_size(c) returns the circulator size. It uses the c.min_circulator() function if c is a random access circulator.

circulator_distance
iterator_distance
is_empty_range
Circulator

## ◆ is_empty_range()

template<class IC >
 bool CGAL::is_empty_range ( const IC & i, const IC & j )

#include <CGAL/circulator.h>

is true if the range [i, j) is empty, false otherwise.

In order to write algorithms that work with iterator ranges as well as with circulator ranges we have to consider the difference of representing an empty range. For iterators this is the range [i,i), while for circulators it would be c == nullptr, the empty sequence test. The function is_empty_range() provides the necessary generic test which accepts an iterator range or a circulator range and says whether the range is empty or not.

Precondition
IC is either a circulator or an iterator type. The range [i, j) is valid.

Example

The following function process_all() accepts a range [i, j) of an iterator or circulator IC and processes each element in this range:

template <class IC>
void process_all( IC i, IC j) {
if (! CGAL::is_empty_range( i, j)) {
do {
process(*i);
} while (++i != j);
}
}
iterator_distance
CGAL_For_all
Circulator_tag
Circulator_traits
Assert_circulator_or_iterator
Circulator

## ◆ iterator_distance()

template<class IC >
 iterator_traits::difference_type CGAL::iterator_distance ( IC ic1, IC ic2 )

#include <CGAL/circulator.h>

The following function returns the distance between either two iterators or two circulators.

circulator_size
circulator_distance
is_empty_range
Circulator_tag
Assert_circulator_or_iterator
CGAL_For_all
Circulator

## ◆ query_circulator_or_iterator() [1/2]

template<class I >
 Iterator_tag CGAL::query_circulator_or_iterator ( const I & i )

#include <CGAL/circulator.h>

This function matches for type I if the iterator category of I belongs to an iterator.

Circulator_tag
Circulator_traits
Assert_circulator
Circulator

## ◆ query_circulator_or_iterator() [2/2]

template<class C >
 Circulator_tag CGAL::query_circulator_or_iterator ( const C & c )

#include <CGAL/circulator.h>

This functiona matches for type C if the iterator category of C belongs to a circulator.

Circulator_tag
Circulator_traits
Assert_circulator
Circulator