BWAPI
|
00001 // Copyright (c) 1997 Utrecht University (The Netherlands), 00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), 00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg 00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), 00005 // and Tel-Aviv University (Israel). All rights reserved. 00006 // 00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00008 // modify it under the terms of the GNU Lesser General Public License as 00009 // published by the Free Software Foundation; version 2.1 of the License. 00010 // See the file LICENSE.LGPL distributed with CGAL. 00011 // 00012 // Licensees holding a valid commercial license may use this file in 00013 // accordance with the commercial license agreement provided with the software. 00014 // 00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 // 00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Circulator/include/CGAL/circulator_impl.h $ 00019 // $Id: circulator_impl.h 44130 2008-07-12 21:58:52Z spion $ 00020 // 00021 // 00022 // Author(s) : Lutz Kettner <kettner@inf.ethz.ch> 00023 00024 #ifndef CGAL_CIRCULATOR_IMPL_H 00025 #define CGAL_CIRCULATOR_IMPL_H 1 00026 00027 #include <CGAL/circulator.h> 00028 00029 CGAL_BEGIN_NAMESPACE 00030 00031 template < class S> 00032 class Forward_circulator_over_struct 00033 : public Forward_circulator_ptrbase<S,std::ptrdiff_t,std::size_t>{ 00034 public: 00035 00036 // DEFINITION 00037 // 00038 // Given a structure `S' that have a data member `S* next' that realizes a 00039 // ring like data structure the adaptor 00040 // `Forward_circulator_over_struct< S>' provides a forward circulator 00041 // for it. If the structure `S' has additionally a second data member of 00042 // type `S* prev' that realizes the reverse direction the adaptor 00043 // `Bidirectional_circulator_over_struct< S>' provides a bidirectional 00044 // circulator for it. In addition, adaptors for const circulators are 00045 // provided with the names `Forward_const_circulator_over_struct< S>' 00046 // and `Bidirectional_const_circulator_over_struct< S>'. A circulator 00047 // becomes invalid whenever the object it refers to gets deleted from the 00048 // data structure. 00049 00050 typedef Forward_circulator_over_struct<S> Self; 00051 typedef Forward_circulator_ptrbase<S,std::ptrdiff_t,std::size_t> Base1; 00052 typedef typename Base1::reference reference; 00053 typedef typename Base1::pointer pointer; 00054 00055 // CREATION 00056 // 00057 // New creation variable is: `circ' 00058 00059 Forward_circulator_over_struct() {} 00060 // a circulator `circ' with singular value. 00061 00062 Forward_circulator_over_struct( S* ptr) 00063 : Forward_circulator_ptrbase<S,std::ptrdiff_t,std::size_t>( ptr) {} 00064 // a circulator `circ' initialized to point to the element `*ptr'. 00065 00066 // OPERATIONS 00067 00068 bool operator==( Nullptr_t p) const { 00069 CGAL_assertion( p == NULL); 00070 return this->_ptr == NULL; 00071 } 00072 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00073 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00074 bool operator!=( const Self& c) const { return !(*this == c); } 00075 reference operator*() const { return *(S*)this->_ptr;} 00076 pointer operator->() const { return (S*)this->_ptr;} 00077 00078 Self& operator++() { 00079 this->_ptr = ((S*)this->_ptr)->next; 00080 return *this; 00081 } 00082 Self operator++(int) { 00083 Self tmp = *this; 00084 ++*this; 00085 return tmp; 00086 } 00087 }; 00088 00089 00090 template < class S> 00091 class Forward_const_circulator_over_struct 00092 : public Forward_circulator_ptrbase<S,std::ptrdiff_t,std::size_t>{ 00093 public: 00094 00095 typedef Forward_const_circulator_over_struct<S> Self; 00096 typedef const S& reference; 00097 typedef const S* pointer; 00098 00099 // CREATION 00100 00101 Forward_const_circulator_over_struct() {} 00102 // a circulator `circ' with singular value. 00103 00104 Forward_const_circulator_over_struct( const S* ptr) 00105 : Forward_circulator_ptrbase<S,std::ptrdiff_t, 00106 std::size_t>((void*)ptr) {} 00107 // a circulator `circ' initialized to point to the element `*ptr'. 00108 00109 // OPERATIONS 00110 00111 bool operator==( Nullptr_t p) const { 00112 CGAL_assertion( p == NULL); 00113 return this->_ptr == NULL; 00114 } 00115 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00116 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00117 bool operator!=( const Self& c) const { return !(*this == c); } 00118 reference operator*() const { return *(const S*)this->_ptr;} 00119 pointer operator->() const { return (const S*)this->_ptr;} 00120 00121 Self& operator++() { 00122 this->_ptr = ((S*)this->_ptr)->next; 00123 return *this; 00124 } 00125 Self operator++(int) { 00126 Self tmp = *this; 00127 ++*this; 00128 return tmp; 00129 } 00130 }; 00131 00132 00133 template < class S> 00134 class Bidirectional_circulator_over_struct 00135 : public Bidirectional_circulator_ptrbase<S,std::ptrdiff_t,std::size_t>{ 00136 public: 00137 00138 typedef Bidirectional_circulator_over_struct<S> Self; 00139 typedef Bidirectional_circulator_ptrbase<S,std::ptrdiff_t, 00140 std::size_t> Base1; 00141 typedef typename Base1::reference reference; 00142 typedef typename Base1::pointer pointer; 00143 00144 // CREATION 00145 // 00146 // New creation variable is: `circ' 00147 00148 Bidirectional_circulator_over_struct() {} 00149 // a circulator `circ' with singular value. 00150 00151 Bidirectional_circulator_over_struct( S* ptr) 00152 : Bidirectional_circulator_ptrbase<S,std::ptrdiff_t, 00153 std::size_t>( ptr) {} 00154 // a circulator `circ' initialized to point to the element `*ptr'. 00155 00156 // OPERATIONS 00157 00158 bool operator==( Nullptr_t p) const { 00159 CGAL_assertion( p == NULL); 00160 return this->_ptr == NULL; 00161 } 00162 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00163 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00164 bool operator!=( const Self& c) const { return !(*this == c); } 00165 reference operator*() const { return *(S*)this->_ptr;} 00166 pointer operator->() const { return (S*)this->_ptr;} 00167 00168 Self& operator++() { 00169 this->_ptr = ((S*)this->_ptr)->next; 00170 return *this; 00171 } 00172 Self operator++(int) { 00173 Self tmp = *this; 00174 ++*this; 00175 return tmp; 00176 } 00177 Self& operator--() { 00178 this->_ptr = ((S*)this->_ptr)->prev; 00179 return *this; 00180 } 00181 Self operator--(int) { 00182 Self tmp = *this; 00183 --*this; 00184 return tmp; 00185 } 00186 }; 00187 00188 00189 template < class S> 00190 class Bidirectional_const_circulator_over_struct 00191 : public Bidirectional_circulator_ptrbase<S,std::ptrdiff_t,std::size_t>{ 00192 public: 00193 00194 typedef Bidirectional_const_circulator_over_struct<S> Self; 00195 typedef const S& reference; 00196 typedef const S* pointer; 00197 00198 // CREATION 00199 00200 Bidirectional_const_circulator_over_struct() {} 00201 // a circulator `circ' with singular value. 00202 00203 Bidirectional_const_circulator_over_struct( const S* ptr) 00204 : Bidirectional_circulator_ptrbase<S,std::ptrdiff_t,std::size_t>( 00205 (void*)ptr) {} 00206 // a circulator `circ' initialized to point to the element `*ptr'. 00207 00208 // OPERATIONS 00209 00210 bool operator==( Nullptr_t p) const { 00211 CGAL_assertion( p == NULL); 00212 return this->_ptr == NULL; 00213 } 00214 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00215 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00216 bool operator!=( const Self& c) const { return !(*this == c); } 00217 reference operator*() const { return *(const S*)this->_ptr;} 00218 pointer operator->() const { return (const S*)this->_ptr;} 00219 00220 Self& operator++() { 00221 this->_ptr = ((S*)this->_ptr)->next; 00222 return *this; 00223 } 00224 Self operator++(int) { 00225 Self tmp = *this; 00226 ++*this; 00227 return tmp; 00228 } 00229 Self& operator--() { 00230 this->_ptr = ((S*)this->_ptr)->prev; 00231 return *this; 00232 } 00233 Self operator--(int) { 00234 Self tmp = *this; 00235 --*this; 00236 return tmp; 00237 } 00238 }; 00239 template < class C> 00240 class Forward_circulator_over_class 00241 : public Forward_circulator_ptrbase<C,std::ptrdiff_t,std::size_t>{ 00242 public: 00243 typedef Forward_circulator_over_class<C> Self; 00244 00245 // DEFINITION 00246 // 00247 // Given a class `C' that has a member function `C* next()' that realizes 00248 // a ring like data structure the adaptor 00249 // `Forward_circulator_over_class<C>' provides a forward circulator 00250 // for it. If the class `C' has additionally a second member function `C* 00251 // prev()' that realizes the reverse direction the adaptor 00252 // `Bidirectional_circulator_over_class<C>' provides a bidirectional 00253 // circulator for it. In addition, adaptors for const circulators are 00254 // provided with the names `Forward_const_circulator_over_class<C>' 00255 // and `Bidirectional_const_circulator_over_class<C>'. A circulator 00256 // becomes invalid whenever the object it refers to gets deleted from the 00257 // data structure. 00258 00259 Forward_circulator_over_class() {} 00260 // a circulator `circ' with a singular value. 00261 00262 Forward_circulator_over_class( C* ptr) 00263 : Forward_circulator_ptrbase<C,std::ptrdiff_t,std::size_t>( ptr) {} 00264 // a circulator `circ' initialized to point to the element `*ptr'. 00265 00266 // 00267 // OPERATIONS 00268 00269 bool operator==( Nullptr_t p) const { 00270 CGAL_assertion( p == NULL); 00271 return this->_ptr == NULL; 00272 } 00273 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00274 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00275 bool operator!=( const Self& c) const { return !(*this == c); } 00276 C& operator*() const { return *(C*)this->_ptr;} 00277 C* operator->() const { return (C*)this->_ptr;} 00278 Self& operator++() { 00279 this->_ptr = ((C*)this->_ptr)->next(); 00280 return *this; 00281 } 00282 Self operator++(int) { 00283 Self tmp = *this; 00284 ++*this; 00285 return tmp; 00286 } 00287 }; 00288 00289 template < class C> 00290 class Forward_const_circulator_over_class 00291 : public Forward_circulator_ptrbase<C,std::ptrdiff_t,std::size_t>{ 00292 public: 00293 typedef Forward_const_circulator_over_class<C> Self; 00294 00295 Forward_const_circulator_over_class() {} 00296 // a circulator `circ' with singular value. 00297 00298 Forward_const_circulator_over_class( const C* ptr) 00299 : Forward_circulator_ptrbase<C,std::ptrdiff_t,std::size_t> 00300 ((void*)ptr) {} 00301 // a circulator `circ' initialized to point to the element `*ptr'. 00302 00303 // 00304 // OPERATIONS 00305 00306 00307 bool operator==( Nullptr_t p) const { 00308 CGAL_assertion( p == NULL); 00309 return this->_ptr == NULL; 00310 } 00311 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00312 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00313 bool operator!=( const Self& c) const { return !(*this == c); } 00314 const C& operator*() const { return *(C*)this->_ptr;} 00315 const C* operator->() const { return (C*)this->_ptr;} 00316 Self& operator++() { 00317 this->_ptr = (void*)(((C*)this->_ptr)->next()); 00318 return *this; 00319 } 00320 Self operator++(int) { 00321 Self tmp = *this; 00322 ++*this; 00323 return tmp; 00324 } 00325 }; 00326 00327 template < class C> 00328 class Bidirectional_circulator_over_class 00329 : public Bidirectional_circulator_ptrbase<C,std::ptrdiff_t,std::size_t>{ 00330 public: 00331 typedef Bidirectional_circulator_over_class<C> Self; 00332 00333 Bidirectional_circulator_over_class() {} 00334 // a circulator `circ' with singular value. 00335 00336 Bidirectional_circulator_over_class( C* ptr) 00337 : Bidirectional_circulator_ptrbase<C,std::ptrdiff_t,std::size_t> 00338 (ptr) {} 00339 // a circulator `circ' initialized to point to the element `*ptr'. 00340 00341 // 00342 // OPERATIONS 00343 00344 bool operator==( Nullptr_t p) const { 00345 CGAL_assertion( p == NULL); 00346 return this->_ptr == NULL; 00347 } 00348 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00349 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00350 bool operator!=( const Self& c) const { return !(*this == c); } 00351 C& operator*() const { return *(C*)this->_ptr;} 00352 C* operator->() const { return (C*)this->_ptr;} 00353 00354 Self& operator++() { 00355 this->_ptr = ((C*)this->_ptr)->next(); 00356 return *this; 00357 } 00358 Self operator++(int) { 00359 Self tmp = *this; 00360 ++*this; 00361 return tmp; 00362 } 00363 Self& operator--() { 00364 this->_ptr = ((C*)this->_ptr)->prev(); 00365 return *this; 00366 } 00367 Self operator--(int) { 00368 Self tmp = *this; 00369 --*this; 00370 return tmp; 00371 } 00372 }; 00373 00374 template < class C> 00375 class Bidirectional_const_circulator_over_class 00376 : public Bidirectional_circulator_ptrbase<C,std::ptrdiff_t,std::size_t>{ 00377 public: 00378 typedef Bidirectional_const_circulator_over_class<C> Self; 00379 // 00380 // CREATION 00381 00382 Bidirectional_const_circulator_over_class() {} 00383 // a circulator `circ' with singular value. 00384 00385 Bidirectional_const_circulator_over_class( const C* ptr) 00386 : Bidirectional_circulator_ptrbase<C,std::ptrdiff_t,std::size_t>( 00387 (void*)ptr) {} 00388 // a circulator `circ' initialized to point to the element `*ptr'. 00389 00390 // 00391 // OPERATIONS 00392 00393 bool operator==( Nullptr_t p) const { 00394 CGAL_assertion( p == NULL); 00395 return this->_ptr == NULL; 00396 } 00397 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00398 bool operator==( const Self& c) const { return this->_ptr == c._ptr; } 00399 bool operator!=( const Self& c) const { return !(*this == c); } 00400 const C& operator*() const { return *(C*)this->_ptr;} 00401 const C* operator->() const { return (C*)this->_ptr;} 00402 00403 Self& operator++() { 00404 this->_ptr = (void*)(((C*)this->_ptr)->next()); 00405 return *this; 00406 } 00407 Self operator++(int) { 00408 Self tmp = *this; 00409 ++*this; 00410 return tmp; 00411 } 00412 Self& operator--() { 00413 this->_ptr = (void*)(((C*)this->_ptr)->prev()); 00414 return *this; 00415 } 00416 Self operator--(int) { 00417 Self tmp = *this; 00418 --*this; 00419 return tmp; 00420 } 00421 }; 00422 template < class A, class T, class U, class I> 00423 class Circulator_over_array 00424 : public Random_access_circulator_ptrbase<T,I,U>{ 00425 U _size; 00426 U _i; 00427 public: 00428 00429 // DEFINITION 00430 // 00431 // Given a data structure `A' that provides random access with an index of 00432 // type `U' to its sequence of stored elements of type `T' with the member 00433 // function `operator[]' the adaptor `Circulator_over_array< A, T, U, 00434 // I>' provides a random access circulator for `A'. The corresponding 00435 // const circulator is `Const_circulator_over_array< A, T, U, I>'. All 00436 // circulators for an array `a' become invalid whenever `a' changes its 00437 // size (due to deletions or insertions). 00438 // 00439 // `A' is a random access data structure and `T' its value type. `U' is 00440 // the unsigned integral type carrying the size of the array and the 00441 // actual index within the container. `I' is the signed integral type used 00442 // as distance type and as index type in the random access circulator. 00443 00444 // TYPES 00445 00446 typedef A Array; 00447 typedef Circulator_over_array<A,T,U,I> Self; 00448 00449 // CREATION 00450 00451 Circulator_over_array() : _size(0), _i(0) {} 00452 // a circulator `circ' with singular value. 00453 00454 Circulator_over_array( A& array, U size, U start = 0) 00455 : Random_access_circulator_ptrbase<T,I,U>( &array), 00456 _size( size), _i(start) {} 00457 // a circulator `circ' initialized to refer to the element 00458 // `(array.*access)(start)'. The circulator `circ' contains a 00459 // singular value if `start >= size'. Precondition: The 00460 // expressions `(array.*access)(i)' are valid in the range 00461 // 0 <= i < `size' . 00462 00463 // OPERATIONS 00464 00465 bool operator==( Nullptr_t p) const { 00466 CGAL_assertion( p == NULL); 00467 return _i >= _size; 00468 } 00469 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00470 bool operator==( const Self& c) const { 00471 CGAL_assertion( this->_ptr == c._ptr); // belong to the same array? 00472 CGAL_assertion( _size == c._size); // same size when instantiated ? 00473 return _i == c._i; 00474 } 00475 bool operator!=( const Self& c) const { return !(*this == c); } 00476 T& operator*() const { 00477 CGAL_assertion( this->_ptr != NULL); 00478 CGAL_assertion( _i < _size); 00479 return ((A*)this->_ptr)->operator[](_i); 00480 } 00481 T* operator->() const { 00482 CGAL_assertion( this->_ptr != NULL); 00483 CGAL_assertion( _i < _size); 00484 return &(((A*)this->_ptr)->operator[](_i)); 00485 } 00486 Self& operator++() { 00487 CGAL_assertion( this->_ptr != NULL); 00488 CGAL_assertion( _i < _size); 00489 ++ _i; 00490 if ( _i >= _size) 00491 _i = 0; 00492 return *this; 00493 } 00494 Self operator++(int) { 00495 Self tmp = *this; 00496 ++*this; 00497 return tmp; 00498 } 00499 Self& operator--() { 00500 CGAL_assertion( this->_ptr != NULL); 00501 CGAL_assertion( _i < _size); 00502 if ( _i <= 0) 00503 _i = _size - 1; 00504 else 00505 -- _i; 00506 return *this; 00507 } 00508 Self operator--(int) { 00509 Self tmp = *this; 00510 --*this; 00511 return tmp; 00512 } 00513 Self& operator+=( I n); 00514 Self operator+( I n) const { 00515 Self tmp = *this; 00516 return tmp += n; 00517 } 00518 Self& operator-=( I n) { return operator+=( -n); } 00519 Self operator-( I n) const { 00520 Self tmp = *this; 00521 return tmp += -n; 00522 } 00523 I operator-( const Self& c) const { 00524 CGAL_assertion( this->_ptr == c._ptr); // belong to the same array? 00525 CGAL_assertion( _size == c._size); // same size when instantiated ? 00526 return _i - c._i; 00527 } 00528 T& operator[](I n) const { 00529 Self tmp = *this; 00530 tmp += n; 00531 return tmp.operator*(); 00532 } 00533 Self min_circulator() { 00534 return Self( *((A*)this->_ptr), _size); 00535 } 00536 // no relational ordering 00537 }; 00538 00539 template < class Dist, class A, class T, class U, class I> 00540 inline 00541 Circulator_over_array< A, T, U, I> 00542 operator+( Dist n, const Circulator_over_array< A, T, U, I>& circ) { 00543 Circulator_over_array< A, T, U, I> tmp = circ; 00544 return tmp += I(n); 00545 } 00546 00547 template < class A, class T, class U, class I> 00548 Circulator_over_array< A, T, U, I>& 00549 Circulator_over_array< A, T, U, I>:: 00550 operator+=( I n) { 00551 CGAL_assertion( this->_ptr != NULL); 00552 CGAL_assertion( _i < _size); 00553 _i = non_negative_mod( (I)(_i) + n, _size); 00554 CGAL_assertion( _i < _size); 00555 return *this; 00556 } 00557 00558 template < class A, class T, class U, class I> 00559 class Const_circulator_over_array 00560 : public Random_access_circulator_ptrbase<T,I,U> { 00561 U _size; 00562 U _i; 00563 public: 00564 00565 // TYPES 00566 00567 typedef A Array; 00568 typedef Const_circulator_over_array<A,T,U,I> Self; 00569 00570 // New creation variable is: `circ' 00571 // 00572 // CREATION 00573 00574 Const_circulator_over_array() : _size(0), _i(0) {} 00575 // a const circulator `circ' with singular value. 00576 00577 Const_circulator_over_array( const A& array, U size, U start = 0) 00578 : Random_access_circulator_ptrbase<T,I,U>( 00579 (void*)(&array)), _size( size), _i(start) {} 00580 // a const circulator `circ' initialized to refer to the element 00581 // `(array.*access)(start)'. The circulator `circ' contains a 00582 // singular value if `start >= size'. Precondition: The 00583 // expressions `(array.*access)(i)' are valid in the range 00584 // 0 <= i < `size' . 00585 00586 // 00587 // OPERATIONS 00588 00589 bool operator==( Nullptr_t p) const { 00590 CGAL_assertion( p == NULL); 00591 return _i >= _size; 00592 } 00593 bool operator!=( Nullptr_t p) const { return !(*this == p); } 00594 bool operator==( const Self& c) const { 00595 CGAL_assertion( this->_ptr == c._ptr); // belong to the same array? 00596 CGAL_assertion( _size == c._size); // same size when instantiated ? 00597 return _i == c._i; 00598 } 00599 bool operator!=( const Self& c) const { return !(*this == c); } 00600 const T& operator*() const { 00601 CGAL_assertion( this->_ptr != NULL); 00602 CGAL_assertion( _i < _size); 00603 return ((const A*)this->_ptr)->operator[](_i); 00604 } 00605 const T* operator->() const { 00606 CGAL_assertion( this->_ptr != NULL); 00607 CGAL_assertion( _i < _size); 00608 return &(((const A*)this->_ptr)->operator[](_i)); 00609 } 00610 Self& operator++() { 00611 CGAL_assertion( this->_ptr != NULL); 00612 CGAL_assertion( _i < _size); 00613 ++ _i; 00614 if ( _i >= _size) 00615 _i = 0; 00616 return *this; 00617 } 00618 Self operator++(int) { 00619 Self tmp = *this; 00620 ++*this; 00621 return tmp; 00622 } 00623 Self& operator--() { 00624 CGAL_assertion( this->_ptr != NULL); 00625 CGAL_assertion( _i < _size); 00626 if ( _i <= 0) 00627 _i = _size - 1; 00628 else 00629 -- _i; 00630 return *this; 00631 } 00632 Self operator--(int) { 00633 Self tmp = *this; 00634 --*this; 00635 return tmp; 00636 } 00637 Self& operator+=( I n); 00638 00639 Self operator+( I n) const { 00640 Self tmp = *this; 00641 return tmp += n; 00642 } 00643 Self& operator-=( I n) { 00644 return operator+=( -n); 00645 } 00646 Self operator-( I n) const { 00647 Self tmp = *this; 00648 return tmp += -n; 00649 } 00650 I 00651 operator-( const Self& c) const { 00652 CGAL_assertion( this->_ptr == c._ptr); // belong to the same array? 00653 CGAL_assertion( _size == c._size); // same size when instantiated ? 00654 return _i - c._i; 00655 } 00656 const T& operator[](I n) const { 00657 Self tmp = *this; 00658 tmp += n; 00659 return tmp.operator*(); 00660 } 00661 Self min_circulator() { 00662 return Self( *((const A*)this->_ptr), _size); 00663 } 00664 // no relational ordering 00665 }; 00666 00667 template < class Dist, class A, class T, class U, class I> 00668 inline 00669 Const_circulator_over_array< A, T, U, I> 00670 operator+( Dist n, const Const_circulator_over_array<A,T,U,I>& circ) { 00671 Const_circulator_over_array< A, T, U, I> tmp = circ; 00672 return tmp += I(n); 00673 } 00674 00675 template < class A, class T, class U, class I> 00676 Const_circulator_over_array< A, T, U, I>& 00677 Const_circulator_over_array< A, T, U, I>:: 00678 operator+=( I n) { 00679 CGAL_assertion( this->_ptr != NULL); 00680 CGAL_assertion( _i < _size); 00681 _i = non_negative_mod( (I)(_i) + n, _size); 00682 CGAL_assertion( _i < _size); 00683 return *this; 00684 } 00685 00686 CGAL_END_NAMESPACE 00687 00688 #endif // CGAL_CIRCULATOR_IMPL_H // 00689 // EOF //