\( \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 4.12 - Handles and Circulators
CGAL::Circulator_from_container< C > Class Template Reference

#include <CGAL/circulator.h>

Definition

The adaptor Circulator_from_container provides a circulator for an STL container C of equal category as the iterator provided by the container.

The iterator must be at least of the forward iterator category. The corresponding non-mutable circulator is called Const_circulator_from_container<C>.

The container type C is supposed to conform to the STL requirements for container (i.e. to have a begin() and an end() iterator as well as the local types reference, const_reference, value_type, size_type, and difference_type).

Types

All types required for circulators are provided.

Operations

The adaptor conforms to the requirements of the corresponding 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_iterator
Circulator

Example

The following program composes two adaptors - from a container to a circulator and back to an iterator. It applies an STL sort algorithm on a STL vector with 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_prog2.cpp

#include <cassert>
#include <vector>
#include <algorithm>
#include <CGAL/circulator.h>
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);
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;
}
Examples:
Circulator/circulator_prog2.cpp.

Creation

 Circulator_from_container ()
 a circulator c on an empty sequence.
 
 Circulator_from_container (C *container)
 a circulator c initialized to refer to the first element in container, i.e. container.begin(). More...
 
 Circulator_from_container (C *container, C::iterator i)
 a circulator c initialized to refer to the element *i in container. More...
 

Constructor & Destructor Documentation

◆ Circulator_from_container() [1/2]

template<typename C >
CGAL::Circulator_from_container< C >::Circulator_from_container ( C *  container)

a circulator c initialized to refer to the first element in container, i.e. container.begin().

The circulator c refers to an empty sequence if the container is empty.

◆ Circulator_from_container() [2/2]

template<typename C >
CGAL::Circulator_from_container< C >::Circulator_from_container ( C *  container,
C::iterator  i 
)

a circulator c initialized to refer to the element *i in container.

Precondition
*i is dereferenceable and refers to container.