CGAL 5.5.2 - Handles and Circulators
CGAL::Container_from_circulator< C > Class Template Reference

#include <CGAL/circulator.h>

Definition

The adaptor Container_from_circulator is a class that converts any circulator type C to a kind of container class, i.e. a class that provides an iterator and a const_iterator type and two member functions (begin() and end()) that return the appropriate iterators.

By analogy to STL container classes these member functions return a const iterator in the case that the container itself is constant and a mutable iterator otherwise.

See also
Circulator_from_iterator
Circulator_from_container
Circulator

Example

The generic reverse() algorithm from the STL can be used with an adaptor if at least a bidirectional circulator c is given.

Circulator c; // c is assumed to be a bidirectional circulator.
reverse( container.begin(), container.end());

Implementation

The iterator adaptor keeps track of the number of rounds a circulator has done around the ring-like data structure (a kind of winding number). It is used to distinguish between the start position and the end position which will be denoted by the same circulator internally. This winding number is zero for the begin()-iterator and one for the end()-iterator. It is incremented whenever the internal circulator passes the begin() position. Two iterators are equal if their internally used circulators and winding numbers are equal. This is more general than necessary since an iterator equal to end()-iterator is not supposed to be incremented any more, which is here still possible in a defined manner.

The implementation is different for random access iterators. The random access iterator has to be able to compute the size of the data structure in constant time. This is for example needed if the difference of the past-the-end iterator and the begin iterator is taken, which is exactly the size of the data structure. Therefore, if the circulator is of the random-access category, the adapter chooses the minimal circulator for the internal anchor position. The minimal circulator is part of the random access circulator requirements, see Page sectionMinCircleRequ. For the random access iterator the adaptor implements a total ordering relation that is currently not required for random access circulators.

Examples:
Circulator/circulator_prog1.cpp, and Circulator/circulator_prog2.cpp.

Types

typedef C Circulator
 
typedef unspecified_type iterator
 
typedef unspecified_type const_iterator
 
typedef unspecified_type value_type
 
typedef unspecified_type reference
 
typedef unspecified_type const_reference
 
typedef unspecified_type pointer
 
typedef unspecified_type const_pointer
 
typedef unspecified_type size_type
 
typedef unspecified_type difference_type
 

Creation

 Container_from_circulator ()
 any iterator of container will have a singular value.
 
 Container_from_circulator (const C &c)
 any iterator of container will have a singular value if the circulator c corresponds to an empty sequence.
 

Operations

The iterator and const_iterator types are of the appropriate iterator category.

In addition to the operations required for their category, they have a member function current_circulator() that returns a circulator pointing to the same position as the iterator does.

iterator begin ()
 the start iterator.
 
const_iterator begin () const
 the start const iterator.
 
iterator end ()
 the past-the-end iterator.
 
const_iterator end () const
 the past-the-end const iterator.