CGAL 6.1 - Handles and Circulators

Loading...
Searching...
No Matches
List of all members
CGAL::Circulator_from_container< C > Class Template Reference
Reference Manual » Adapters for Iterators and Containers

`#include <CGAL/circulator.h>`

## Definition

template<typename C>
class CGAL::Circulator_from_container< C >

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 CGAL::Circulator_from_container< std::vector<int> > Circulator;
typedef CGAL::Container_from_circulator<Circulator> Container;
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;
}
CGAL::Circulator_from_container
The adaptor Circulator_from_container provides a circulator for an STL container C of equal category ...
Definition: circulator.h:151
CGAL::Container_from_circulator
The adaptor Container_from_circulator is a class that converts any circulator type C to a kind of con...
Definition: circulator.h:430
Circulator
A Circulator is similar to an Iterator, with the difference that it is designed for circular data str...
Definition: Circulator.h:297
Container
Iterator

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()`.
| Circulator_from_container (C *container, C::iterator i)
| a circulator `c` initialized to refer to the element `*i` in `container`.

## 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`.