I is the appropriate iterator type, T its value type, Size the unsigned integral value to hold the possible number of items in a sequence, and Dist is a signed integral value, the distance type between two iterators of the same sequence.
#include < CGAL/circulator.h>
typedef I | iterator; | |
typedef T | value_type; | |
typedef Size | size_type; | |
typedef Dist | difference_type; |
CGAL_Forward_circulator_from_iterator< I, T, Size, Dist> c; | |||
a circulator c with a singular value.
| |||
| |||
a circulator c initialized to refer to the element
*begin in a range [begin,end
). The circulator c contains a singular value if
begin==end.
|
CGAL_Forward_const_circulator_from_iterator< I, T, Size, Dist> c; | |||
a const circulator c with a singular value.
| |||
| |||
a const circulator c initialized to refer to the element
*begin in a range [begin,end
). The circulator c contains a singular value if
begin==end.
|
The bidirectional and random access circulators have similar constructors. The default construction is shown here to present the adaptor names.
CGAL_Bidirectional_circulator_from_iterator< I, T, Size, Dist> c; |
CGAL_Bidirectional_const_circulator_from_iterator< I, T, Size, Dist> c; |
CGAL_Random_access_circulator_from_iterator< I, T, Size, Dist> c; |
CGAL_Random_access_const_circulator_from_iterator< I, T, Size, Dist> c; |
/* circulator_prog1.C */ /* ------------------------------ */ #include <assert.h> #include <vector.h> #include <algo.h> #include <CGAL/circulator.h> typedef CGAL_Random_access_circulator_from_iterator< vector<int>::iterator, vector<int>::value_type, vector<int>::size_type, vector<int>::difference_type > Circulator; typedef CGAL_Random_access_container_from_circulator<Circulator> Container; typedef Container::iterator Iterator; main() { vector<int> v; v.push_back(5); v.push_back(2); v.push_back(9); Circulator c( v.begin(), v.end()); Container container( c); 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 are random access circulators 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 CGAL_Random_access_circulator_from_iterator< T*, T, size_t, ptrdiff_t> c( b,e) is a random circulator c over this array.