\( \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 5.0.3 - Handles and Circulators
CGAL::Circulator_from_iterator< I > Class Template Reference

#include <CGAL/circulator.h>

Definition

The adaptor Circulator_from_iterator converts two iterators of type I, a begin and a past-the-end value, to a circulator of equal category.

The iterator must be at least of the forward iterator category. The circulator will be mutable or non-mutable according to the iterator. Iterators provide no size_type. This adapter assumes std::size_t instead.

Operations

The adaptor conforms to the requirements of the respective circulator category. An additional member function current_iterator() returns the current iterator pointing to the same position as the circulator does.

See also
Container_from_circulator
Circulator_from_container
Circulator

Example

The following program composes two adaptors - from an iterator to a circulator and back to an iterator. It applies an STL sort algorithm on a STL vector containing three elements. The resulting vector will be [2 5 9] as it is checked by the assertions. The program is part of the CGAL distribution.


File Circulator/circulator_prog1.cpp

#include <cassert>
#include <vector>
#include <algorithm>
#include <CGAL/circulator.h>
typedef std::vector<int>::iterator I;
typedef Container::iterator Iterator;
int main() {
std::vector<int> v;
v.push_back(5);
v.push_back(2);
v.push_back(9);
Circulator c( v.begin(), v.end());
Container container( c);
std::sort( container.begin(), container.end());
Iterator i = container.begin();
assert( *i == 2);
i++; assert( *i == 5);
i++; assert( *i == 9);
i++; assert( i == container.end());
return 0;
}

Another example usage for this adaptor is a random access circulator over the built-in C arrays. Given an array of type T* with a begin pointer b and a past-the-end pointer e the adaptor Circulator_from_iterator<T*> c(b,e) is a random access circulator c over this array.

Examples:
Circulator/circulator_prog1.cpp.

Types

In addition all types required for circulators are provided.

typedef I iterator
 

Creation

 Circulator_from_iterator ()
 a circulator c on an empty sequence.
 
 Circulator_from_iterator (const I &begin, const I &end, const I &cur=begin)
 a circulator c initialized to refer to the element *cur in a range [begin, end). More...
 
 Circulator_from_iterator (const Circulator_from_iterator< I, T, Size, Dist > &d, const I &cur)
 a copy of circulator d referring to the element *cur. More...
 

Constructor & Destructor Documentation

◆ Circulator_from_iterator() [1/2]

template<typename I>
CGAL::Circulator_from_iterator< I >::Circulator_from_iterator ( const I &  begin,
const I &  end,
const I &  cur = begin 
)

a circulator c initialized to refer to the element *cur in a range [begin, end).

The circulator c refers to a empty sequence if begin==end.

◆ Circulator_from_iterator() [2/2]

template<typename I>
CGAL::Circulator_from_iterator< I >::Circulator_from_iterator ( const Circulator_from_iterator< I, T, Size, Dist > &  d,
const I &  cur 
)

a copy of circulator d referring to the element *cur.

The circulator c refers to a empty sequence if d does so.