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>
|
|
|
|
|
|
|
|
|
|
|
| |||
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.
|
| |||
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.
|
|
|
|
/* circulator_prog1.C */ /* ------------------------------ */ #include <CGAL/basic.h> #include <assert.h> #include <vector.h> #include <algo.h> #include <CGAL/circulator.h> typedef vector<int>::iterator I; typedef vector<int>::value_type V; typedef vector<int>::size_type S; typedef vector<int>::difference_type D; typedef CGAL_Random_access_circulator_from_iterator<I,V,S,D> 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.