CGAL 5.4 - 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 function matches for type C if the iterator category of C belongs to a circulator. More... | |
#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:
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
.
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)
.
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.
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.
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:
iterator_traits<IC>::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.
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 CGAL::query_circulator_or_iterator | ( | const C & | c | ) |
#include <CGAL/circulator.h>
This function matches for type C
if the iterator category of C
belongs to a circulator.