Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
circulator.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1997 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 //
33 // release : CGAL-2.2
34 // release_date : 2000, September 30
35 //
36 // file : include/CGAL/circulator.h
37 // package : Circulator (3.15)
38 // chapter : $CGAL_Chapter: Circulators $
39 // source : circulator.fw
40 // revision : $Revision: 1.1.1.1 $
41 // revision_date : $Date: 2001/07/05 22:17:48 $
42 // author(s) : Lutz Kettner
43 //
44 // coordinator : INRIA, Sophia Antipolis
45 //
46 // Circulator support and Adaptors between circulators and iterators.
47 // email : contact@cgal.org
48 // www : http://www.cgal.org
49 //
50 // ======================================================================
51 
52 #ifndef CGAL_CIRCULATOR_H
53 #define CGAL_CIRCULATOR_H 1
54 
55 #ifndef CGAL_BASIC_H
56 #include <CGAL/basic.h>
57 #endif
58 #ifndef CGAL_PROTECT_CSTDDEF
59 #include <cstddef>
60 #define CGAL_PROTECT_CSTDDEF
61 #endif
62 #ifndef CGAL_PROTECT_FUNCTIONAL
63 #include <functional>
64 #define CGAL_PROTECT_FUNCTIONAL
65 #endif
66 #ifndef CGAL_PROTECT_ITERATOR
67 #include <iterator>
68 #define CGAL_PROTECT_ITERATOR
69 #endif
70 #ifndef CGAL_CIRCULATOR_BASES_H
71 #include <CGAL/circulator_bases.h>
72 #endif
73 
74 #ifndef CGAL_NULL_TYPE
75 #if defined( __GNUG__ )
76  // (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 91))
77 #define CGAL_NULL_TYPE const void*
78 #define CGAL_CIRC_NULL 0
79 #else // __GNUG__ //
80 #define CGAL_NULL_TYPE int
81 #define CGAL_CIRC_NULL NULL
82 #endif // __GNUG__ //
83 #endif // CGAL_NULL_TYPE //
84 
85 // These are name redefinitions for backwards compatibility
86 // with the pre iterator-traits style adaptors.
87 
88 #define Forward_container_from_circulator \
89  Container_from_circulator
90 #define Bidirectional_container_from_circulator \
91  Container_from_circulator
92 #define Random_access_container_from_circulator \
93  Container_from_circulator
94 
95 #define Forward_circulator_from_iterator \
96  Circulator_from_iterator
97 #define Forward_const_circulator_from_iterator \
98  Circulator_from_iterator
99 #define Bidirectional_circulator_from_iterator \
100  Circulator_from_iterator
101 #define Bidirectional_const_circulator_from_iterator \
102  Circulator_from_iterator
103 #define Random_access_circulator_from_iterator \
104  Circulator_from_iterator
105 #define Random_access_const_circulator_from_iterator \
106  Circulator_from_iterator
107 
108 #define Forward_circulator_from_container \
109  Circulator_from_container
110 #define Bidirectional_circulator_from_container \
111  Circulator_from_container
112 #define Random_access_circulator_from_container \
113  Circulator_from_container
114 
115 #define Forward_const_circulator_from_container \
116  Const_circulator_from_container
117 #define Bidirectional_const_circulator_from_container \
118  Const_circulator_from_container
119 #define Random_access_const_circulator_from_container \
120  Const_circulator_from_container
121 
122 
123 
125 
126 template <class C>
129 };
133 };
137 };
141 };
142 
143 // Circulator_size_traits are used by general adaptors for
144 // iterators and circulators. For example the N_step_adaptor
145 // works for iterators as well as for circulators. Circulators
146 // need a local type called size_type which is not needed for
147 // iterators. But a general adaptor has to declare this type
148 // in any case and the following Circulator_size_traits helps
149 // in this case. It declares size_type to be std::size_t for
150 // iterators and to be C::size_type for any circulator C.
151 template <class Tag, class IC>
153  typedef std::size_t size_type;
154 };
155 #ifndef CGAL_CFG_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION
156 template <class C>
158  typedef typename C::size_type size_type;
159 };
160 template <class C>
162  typedef typename C::size_type size_type;
163 };
164 template <class C>
166  typedef typename C::size_type size_type;
167 };
168 #endif // CGAL_CFG_NO_PARTIAL_CLASS_TEMPLATE_SPECIALISATION //
169 
170 template <class CCtg>
172  typedef CCtg iterator_category;
173 };
176  typedef std::forward_iterator_tag iterator_category;
177 };
181  typedef std::bidirectional_iterator_tag iterator_category;
182 };
186  typedef std::random_access_iterator_tag iterator_category;
187 };
188 
189 template <class ICtg>
191  typedef ICtg iterator_category;
192 };
194 struct I_Circulator_from_iterator_traits< std::forward_iterator_tag> {
196 };
198 struct I_Circulator_from_iterator_traits<std::bidirectional_iterator_tag> {
200 };
202 struct I_Circulator_from_iterator_traits<std::random_access_iterator_tag> {
204 };
205 
206 template <class C>
208  typedef std::iterator_traits<C> traits;
209  typedef typename traits::iterator_category ICAT;
211  typedef typename C_traits::category category;
212 
215 
218 };
219 
220 template <class C>
223  typedef typename Circulator_traits<C>::category category;
224  return category();
225 }
226 /* A function that asserts a specific compile time tag */
227 /* forcing its two arguments to have equal type. */
228 /* It is encapsulated with #ifdef since it will be defined also elsewhere. */
229 #ifndef CGAL_ASSERT_COMPILE_TIME_TAG
230 #define CGAL_ASSERT_COMPILE_TIME_TAG 1
231 template <class Base>
233  void match_compile_time_tag( const Base&) const {}
234 };
235 template< class Tag, class Derived>
236 inline void Assert_compile_time_tag( const Tag&, const Derived& b) {
239 }
240 #endif
241 
242 template <class C> inline
243 void Assert_circulator( const C &c) {
245 }
246 template <class I> inline
247 void Assert_iterator( const I &i) {
249 }
250 template <class I> inline
251 void Assert_input_category( const I &i) {
252  Assert_compile_time_tag( std::input_iterator_tag(),
253  // std::iterator_category(i));
254  std::iterator_traits<I>::iterator_category());
255 }
256 template <class I> inline
257 void Assert_output_category( const I &i) {
258  Assert_compile_time_tag( std::output_iterator_tag(),
259  //std::iterator_category(i));
260  std::iterator_traits<I>::iterator_category());
261 }
262 template <class IC> inline
263 void Assert_forward_category( const IC &ic) {
264  Assert_compile_time_tag( std::forward_iterator_tag(),
265  //std::iterator_category(ic));
266  std::iterator_traits<IC>::iterator_category());
267 }
268 template <class IC> inline
270  Assert_compile_time_tag( std::bidirectional_iterator_tag(),
271  //std::iterator_category(ic));
272  std::iterator_traits<IC>::iterator_category());
273 
274 }
275 template <class IC> inline
277  Assert_compile_time_tag( std::random_access_iterator_tag(),
278  //std::iterator_category(ic));
279  std::iterator_traits<IC>::iterator_category());
280 
281 }
282 
283 // The assert at-least-category functions use the following
284 // functions to resolve properly. Note the proper order of the
285 // arguments: 1st is the to be type, 2nd is the actual type.
286 inline void I_Has_to_be_at_least( std::input_iterator_tag,
287  std::input_iterator_tag){}
288 inline void I_Has_to_be_at_least( std::input_iterator_tag,
289  std::forward_iterator_tag){}
290 inline void I_Has_to_be_at_least( std::input_iterator_tag,
291  std::bidirectional_iterator_tag){}
292 inline void I_Has_to_be_at_least( std::input_iterator_tag,
293  std::random_access_iterator_tag){}
294 
295 inline void I_Has_to_be_at_least( std::output_iterator_tag,
296  std::output_iterator_tag){}
297 inline void I_Has_to_be_at_least( std::output_iterator_tag,
298  std::forward_iterator_tag){}
299 inline void I_Has_to_be_at_least( std::output_iterator_tag,
300  std::bidirectional_iterator_tag){}
301 inline void I_Has_to_be_at_least( std::output_iterator_tag,
302  std::random_access_iterator_tag){}
303 
304 inline void I_Has_to_be_at_least( std::forward_iterator_tag,
305  std::forward_iterator_tag){}
306 inline void I_Has_to_be_at_least( std::forward_iterator_tag,
307  std::bidirectional_iterator_tag){}
308 inline void I_Has_to_be_at_least( std::forward_iterator_tag,
309  std::random_access_iterator_tag){}
310 
311 inline void I_Has_to_be_at_least( std::bidirectional_iterator_tag,
312  std::bidirectional_iterator_tag){}
313 inline void I_Has_to_be_at_least( std::bidirectional_iterator_tag,
314  std::random_access_iterator_tag){}
315 
316 inline void I_Has_to_be_at_least( std::random_access_iterator_tag,
317  std::random_access_iterator_tag){}
318 
319 // The is-at-least assertions.
320 template <class I> inline
322  I_Has_to_be_at_least( std::input_iterator_tag(),
323  //std::iterator_category(i));
324  std::iterator_traits<I>::iterator_category());
325 }
326 template <class I> inline
328  I_Has_to_be_at_least( std::output_iterator_tag(),
329  //std::iterator_category(i));
330  std::iterator_traits<I>::iterator_category());
331 }
332 template <class IC> inline
334  I_Has_to_be_at_least( std::forward_iterator_tag(),
335  //std::iterator_category(ic));
336  std::iterator_traits<IC>::iterator_category());
337 }
338 template <class IC> inline
340  I_Has_to_be_at_least( std::bidirectional_iterator_tag(),
341  //std::iterator_category(ic)) ;
342  std::iterator_traits<IC>::iterator_category());
343  }
344 template <class IC> inline
346  I_Has_to_be_at_least( std::random_access_iterator_tag(),
347  //std::iterator_category(ic));
348  std::iterator_traits<IC>::iterator_category());
349 }
350 
351 template< class C> inline
352 bool I_is_empty_range( const C& c1, const C&, Circulator_tag){
353  return c1 == CGAL_CIRC_NULL;
354 }
355 
356 template< class I> inline
357 bool I_is_empty_range( const I& i1, const I& i2, Iterator_tag){
358  return i1 == i2;
359 }
360 
361 template< class IC> inline
362 bool is_empty_range( const IC& ic1, const IC& ic2){
363  // is `true' if the range [`ic1, ic2') is empty, `false' otherwise.
364  // Precondition: `T' is either a circulator or an iterator type. The
365  // range [`ic1, ic2') is valid.
366  return I_is_empty_range( ic1, ic2, query_circulator_or_iterator(ic1));
367 }
368 
369 struct Circulator_or_iterator_tag {}; // any circulator or iterator.
370 
371 inline
375 }
376 inline
380 }
381 
382 template< class IC> inline
387 }
388 
389 #define CGAL_For_all( ic1, ic2) \
390  for ( bool _circ_loop_flag = ! ::CGAL::is_empty_range( ic1, ic2); \
391  _circ_loop_flag; \
392  _circ_loop_flag = ((++ic1) != (ic2)) )
393 
394 #define CGAL_For_all_backwards( ic1, ic2) \
395  for ( bool _circ_loop_flag = ! ::CGAL::is_empty_range( ic1, ic2); \
396  _circ_loop_flag; \
397  _circ_loop_flag = ((ic1) != (--ic2)) )
398 
399 
400 
401 template <class C> inline
402 typename C::size_type
403 I_min_circulator_size( const C& c) {
406  typedef typename C::size_type size_type;
407  size_type n = 0;
408  if ( c != CGAL_CIRC_NULL) {
409  n = (c-1) - c + 1;
410  CGAL_assertion(n > 0);
411  }
412  return n;
413 }
414 
415 template <class C>
416 typename C::size_type
418  // Simply count.
419  if ( c == CGAL_CIRC_NULL)
420  return 0;
421  typedef typename C::size_type size_type;
422  size_type n = 0;
423  C d = c;
424  do {
425  ++n;
426  ++d;
427  } while( c != d);
428  return n;
429 }
430 template <class C> inline
431 typename C::size_type
434 }
435 template <class C> inline
436 typename C::size_type
438  return I_min_circulator_size( c.min_circulator());
439 }
440 
441 template <class C> inline
442 typename C::size_type
443 circulator_size( const C& c) {
444  return I_circulator_size( c,
445  //std::iterator_category(c));
446  std::iterator_traits<C>::iterator_category());
447 }
448 template <class C>
449 typename C::difference_type
451  // Simply count.
452  if ( c == CGAL_CIRC_NULL)
453  return 0;
454  typedef typename C::difference_type difference_type;
455  difference_type n = 0;
456  do {
457  ++n;
458  } while( ++c != d);
459  return n;
460 }
461 template <class C> inline
462 typename C::difference_type
463 I_circulator_distance( const C& c, const C& d,
466 }
467 template <class C> inline
468 typename C::difference_type
469 I_circulator_distance( const C& c, const C& d,
471  typedef typename C::difference_type difference_type;
472  typedef typename C::size_type size_type;
473  if ( d - c > 0)
474  return (d - c);
475  return difference_type( size_type( I_min_circulator_size(
476  c.min_circulator()))) - (c-d);
477 }
478 
479 template <class C> inline
480 typename C::difference_type
481 circulator_distance( const C& c, const C& d) {
482  return I_circulator_distance( c, d,
483  //std::iterator_category(c));
484  std::iterator_traits<C>::iterator_category());
485 }
486 template <class C> inline
487 typename std::iterator_traits<C>::difference_type
488 I_iterator_distance(const C& c1, const C& c2, Circulator_tag) {
489  return circulator_distance( c1, c2);
490 }
491 
492 template <class I> inline
493 typename std::iterator_traits<I>::difference_type
494 I_iterator_distance(const I& i1, const I& i2, Iterator_tag) {
495  return std::distance( i1, i2);
496 }
497 
498 template <class IC> inline
499 typename std::iterator_traits<IC>::difference_type
500 iterator_distance(const IC& ic1, const IC& ic2) {
501  return I_iterator_distance( ic1, ic2,
503 }
504 template <class C> inline
506  return c;
507 }
508 template <class C> inline
510  return c;
511 }
512 template <class C> inline
514  return c.min_circulator();
515 }
516 template <class C> inline
518  return I_get_min_circulator( c,
519  //std::iterator_category(c));
520  std::iterator_traits<C>::iterator_category());
521 }
522 template<class I, class U> inline
523 I non_negative_mod(I n, U m) {
524  CGAL_precondition( m > 0);
525  #if (-1 % 3) > 0
526  n = n % m;
527  #else
528  if (n < 0)
529  n = - (( - n - 1) % m) + m - 1;
530  else
531  n = n % m;
532  #endif
533  CGAL_postcondition( n >= 0);
534  return n;
535 }
536 
537 template < class C, class Ref, class Ptr>
539 private:
540  // The m_anchor is normalized to be a minimal circulator.
541  const C* m_anchor;
544 
545  typedef std::iterator_traits<C> I_traits;
546  typedef typename I_traits::iterator_category I_Iter_cat;
548 
549 public:
550 //
551 // TYPES
552 
553  typedef C Circulator;
555 
557 
558  typedef typename C::value_type value_type;
559  typedef typename C::difference_type difference_type;
560  typedef typename C::size_type size_type;
561  typedef typename C::reference reference;
562  typedef typename C::pointer pointer;
563 
564 //
565 // CREATION
566 
568 
569  Iterator_from_circulator( const C* circ, int n)
570  : m_anchor( circ), current( *circ), m_winding(n) {}
571 
572  // Allow construction from Iterator_from_circulator with
573  // assignment compatible circulator CC:
574  template <class CC, class CREF, class CPTR>
577  : m_anchor( c.anchor()), current( c.current_circulator()),
578  m_winding(c.winding()) {}
579 
580 //
581 // OPERATIONS
582 
583  bool operator==( const Self& i) const {
584  CGAL_assertion( m_anchor == i.m_anchor); // same anchor?
585  return ( current == i.current) && ( m_winding == i.m_winding);
586  }
587  bool operator!=( const Self& i) const {
588  return !(*this == i);
589  }
590  Ref operator*() const {
593  return Ref(*current);
594  }
595  Ptr operator->() const {
598  return Ptr(current.operator->());
599  }
603  ++current;
604  if ( current == *m_anchor)
605  ++m_winding;
606  return *this;
607  }
609  Self tmp = *this;
610  ++*this;
611  return tmp;
612  }
616  if ( current == *m_anchor)
617  --m_winding;
618  --current;
619  return *this;
620  }
622  Self tmp = *this;
623  --*this;
624  return tmp;
625  }
629  if ( n < 0 && current == *m_anchor) // We are leaving the anchor.
630  --m_winding;
631  current += n;
632  if ( n > 0 && current == *m_anchor) // Back again at the anchor.
633  ++m_winding;
634  return *this;
635  }
637  Self tmp = *this;
638  return tmp += n;
639  }
641  return operator+=( -n);
642  }
644  Self tmp = *this;
645  return tmp += -n;
646  }
647 #ifndef _MSC_VER
648  difference_type operator-( const Self& i) const;
649 #else
650  difference_type operator-( const Self& i) const {
653  CGAL_assertion( m_anchor == i.m_anchor);
654  if ( m_winding != i.m_winding) {
656  return (current - *m_anchor) - (i.current - *m_anchor)
657  + s * (m_winding - i.m_winding);
658  }
659  return (current - *m_anchor) - (i.current - *m_anchor);
660  }
661 #endif
662 
664  Self tmp = *this;
665  tmp += n;
666  return tmp.operator*();
667  }
668  bool operator<( const Self& i) const {
672  return ( (m_winding < i.m_winding)
673  || ( (m_winding == i.m_winding)
674  && (current - *m_anchor) < (i.current - *m_anchor)
675  )
676  );
677  }
678  bool operator> ( const Self& i) const { return i < *this; }
679  bool operator<=( const Self& i) const { return !(i < *this); }
680  bool operator>=( const Self& i) const { return !(*this < i); }
681 
682  const C* anchor() const { return m_anchor;}
683  int winding() const { return m_winding;}
685 };
686 
687 template < class Dist, class C, class Ref, class Ptr>
691  return tmp += n;
692 }
693 
694 #ifndef _MSC_VER
695 template < class C, class Ref, class Ptr>
696 typename C::difference_type
699  CGAL_assertion( m_anchor != CGAL_CIRC_NULL);
700  CGAL_assertion( current != CGAL_CIRC_NULL);
701  CGAL_assertion( m_anchor == i.m_anchor);
702  if ( m_winding != i.m_winding) {
703  difference_type s = I_min_circulator_size( *m_anchor);
704  return (current - *m_anchor) - (i.current - *m_anchor)
705  + s * (m_winding - i.m_winding);
706  }
707  return (current - *m_anchor) - (i.current - *m_anchor);
708 }
709 #endif // _MSC_VER //
710 
711 template < class C >
713 private:
715 public:
716 //
717 // CREATION
718 
720  // the resulting iterators will have a singular value.
721 
722  Container_from_circulator(const C& c)
723  // The anchor is normalized to be a minimal circulator.
724  : anchor(get_min_circulator(c)) {}
725  // the resulting iterators will have a singular value if the
726  // circulator `c' is singular.
727 
728 //
729 // TYPES
730 
731 typedef C Circulator;
732 
733 typedef typename C::value_type value_type;
737 typedef const value_type* const_pointer;
738 typedef typename C::size_type size_type;
739 typedef typename C::difference_type difference_type;
740 
745 //
746 // OPERATIONS
747 
749  // the start iterator.
750  return iterator( &anchor, 0);
751  }
753  // the start const iterator.
754  return const_iterator( &anchor, 0);
755  }
757  // the past-the-end iterator.
758  return anchor == CGAL_CIRC_NULL ? iterator( &anchor, 0)
759  : iterator( &anchor, 1);
760  }
761  const_iterator end() const {
762  // the past-the-end const iterator.
763  return anchor == CGAL_CIRC_NULL ? const_iterator( &anchor, 0)
764  : const_iterator( &anchor, 1);
765  }
766 };
767 template < class Ctnr>
769 public:
770 // TYPES
771 
773  typedef Ctnr Container;
774  typedef typename Ctnr::iterator iterator;
775  typedef typename Ctnr::value_type value_type;
776  typedef typename Ctnr::reference reference;
777  typedef value_type* pointer;
778  typedef typename Ctnr::size_type size_type;
779  typedef typename Ctnr::difference_type difference_type;
780 
781  typedef std::iterator_traits<iterator> ITraits;
782  typedef typename ITraits::iterator_category Icategory;
785 
786 private:
787  Ctnr* ctnr;
789 
790 public:
791 // CREATION
792 
794  Circulator_from_container( Ctnr* c) : ctnr(c), i(c->begin()) {}
795  Circulator_from_container( Ctnr* c, iterator j) : ctnr(c), i(j) {}
796 
797 // Gnu-bug workaround: define operator= explicitly.
798  Self& operator=( const Self& c) {
799  ctnr = c.ctnr;
800  i = c.i;
801  return *this;
802  }
803 
804 // OPERATIONS
805 
806  bool operator==( CGAL_NULL_TYPE p) const {
808  return (ctnr == NULL) || (ctnr->begin() == ctnr->end());
809  }
810  bool operator!=( CGAL_NULL_TYPE p) const { return !(*this == p); }
811  bool operator==( const Self& c) const { return i == c.i; }
812  bool operator!=( const Self& c) const { return !(*this == c); }
814  CGAL_assertion( ctnr != NULL);
815  CGAL_assertion( i != ctnr->end());
816  return *i;
817  }
818  pointer operator->() const {
819  CGAL_assertion( ctnr != NULL);
820  CGAL_assertion( i != ctnr->end());
821  return i.operator->();
822  }
824  CGAL_assertion( ctnr != NULL);
825  CGAL_assertion( i != ctnr->end());
826  ++i;
827  if ( i == ctnr->end())
828  i = ctnr->begin();
829  return *this;
830  }
832  Self tmp= *this;
833  ++*this;
834  return tmp;
835  }
837  CGAL_assertion( ctnr != NULL);
838  CGAL_assertion( i != ctnr->end());
839  if ( i == ctnr->begin())
840  i = ctnr->end();
841  --i;
842  return *this;
843  }
845  Self tmp = *this;
846  --*this;
847  return tmp;
848  }
849 #ifndef _MSC_VER
851 #else
853  CGAL_assertion( ctnr != NULL);
854  CGAL_assertion( i != ctnr->end());
855  typename Ctnr::difference_type j = i - ctnr->begin();
856  typename Ctnr::difference_type size = ctnr->size();
857  CGAL_assertion( j >= 0);
858  CGAL_assertion( size >= 0);
859  j = non_negative_mod( j + n, size);
860  CGAL_assertion( j >= 0);
861  CGAL_assertion( j < size);
862  i = ctnr->begin() + j;
863  return *this;
864  }
865 #endif
867  Self tmp = *this;
868  return tmp += n;
869  }
872  Self tmp = *this;
873  return tmp += -n;
874  }
875  difference_type operator-( const Self& c) const {
876  CGAL_assertion( ctnr != NULL);
877  CGAL_assertion( c.ctnr != NULL);
878  return i - c.i;
879  }
881  Self tmp = *this;
882  tmp += n;
883  return *tmp;
884  }
885  iterator current_iterator() const { return i;}
886  Self min_circulator() const { return Self(ctnr); }
887  Ctnr* container() const { return ctnr; }
888 };
889 
890 template <class Ctnr>
891 inline
896  return tmp += n;
897 }
898 
899 #ifndef _MSC_VER
900 template <class Ctnr>
903 operator+=( typename Ctnr::difference_type n) {
904  CGAL_assertion( ctnr != NULL);
905  CGAL_assertion( i != ctnr->end());
906  typename Ctnr::difference_type j = i - ctnr->begin();
907  typename Ctnr::difference_type size = ctnr->size();
908  CGAL_assertion( j >= 0);
909  CGAL_assertion( size >= 0);
910  j = non_negative_mod( j + n, size);
911  CGAL_assertion( j >= 0);
912  CGAL_assertion( j < size);
913  i = ctnr->begin() + j;
914  return *this;
915 }
916 #endif // _MSC_VER //
917 
918 
919 template < class Ctnr>
921 public:
922 // TYPES
923 
926  typedef Ctnr Container;
927  typedef typename Ctnr::const_iterator const_iterator;
928  typedef typename Ctnr::value_type value_type;
929  typedef typename Ctnr::const_reference reference;
930  typedef const value_type* pointer;
931  typedef typename Ctnr::size_type size_type;
932  typedef typename Ctnr::difference_type difference_type;
933 
934  typedef std::iterator_traits<const_iterator> ITraits;
935  typedef typename ITraits::iterator_category Icategory;
938 
939 private:
940  const Ctnr* ctnr;
942 
943 public:
944 // CREATION
945 
948  : ctnr(c), i(c->begin()) {}
950  : ctnr(c), i(j) {}
952  : ctnr( c.container()), i( c.current_iterator()) {}
953 
954 // Gnu-bug workaround: define operator= explicitly.
955  Self& operator=( const Self& c) {
956  ctnr = c.ctnr;
957  i = c.i;
958  return *this;
959  }
960 
961 // OPERATIONS
962 
963  bool operator==( CGAL_NULL_TYPE p) const {
965  return (ctnr == NULL) || (ctnr->begin() == ctnr->end());
966  }
967  bool operator!=( CGAL_NULL_TYPE p) const { return !(*this == p); }
968  bool operator==( const Self& c) const { return i == c.i; }
969  bool operator!=( const Self& c) const { return !(*this == c); }
971  CGAL_assertion( ctnr != NULL);
972  CGAL_assertion( i != ctnr->end());
973  return *i;
974  }
975  pointer operator->() const {
976  CGAL_assertion( ctnr != NULL);
977  CGAL_assertion( i != ctnr->end());
978  return i.operator->();
979  }
981  CGAL_assertion( ctnr != NULL);
982  CGAL_assertion( i != ctnr->end());
983  ++i;
984  if ( i == ctnr->end())
985  i = ctnr->begin();
986  return *this;
987  }
989  Self tmp= *this;
990  ++*this;
991  return tmp;
992  }
994  CGAL_assertion( ctnr != NULL);
995  CGAL_assertion( i != ctnr->end());
996  if ( i == ctnr->begin())
997  i = ctnr->end();
998  --i;
999  return *this;
1000  }
1002  Self tmp = *this;
1003  --*this;
1004  return tmp;
1005  }
1006 #ifndef _MSC_VER
1008 #else
1010  CGAL_assertion( ctnr != NULL);
1011  CGAL_assertion( i != ctnr->end());
1012  typename Ctnr::difference_type j = i - ctnr->begin();
1013  typename Ctnr::difference_type size = ctnr->size();
1014  CGAL_assertion( j >= 0);
1015  CGAL_assertion( size >= 0);
1016  j = non_negative_mod( j + n, size);
1017  CGAL_assertion( j >= 0);
1018  CGAL_assertion( j < size);
1019  i = ctnr->begin() + j;
1020  return *this;
1021  }
1022 #endif
1024  Self tmp = *this;
1025  return tmp += n;
1026  }
1029  Self tmp = *this;
1030  return tmp += -n;
1031  }
1032  difference_type operator-( const Self& c) const {
1033  CGAL_assertion( ctnr != NULL);
1034  CGAL_assertion( c.ctnr != NULL);
1035  return i - c.i;
1036  }
1038  Self tmp = *this;
1039  tmp += n;
1040  return *tmp;
1041  }
1042  const_iterator current_iterator() const { return i;}
1043  Self min_circulator() const { return Self(ctnr); }
1044  const Ctnr* container() const { return ctnr; }
1045 };
1046 
1047 template <class Ctnr>
1048 inline
1051  difference_type n,
1054  return tmp += n;
1055 }
1056 
1057 #ifndef _MSC_VER
1058 template <class Ctnr>
1061 operator+=( typename Ctnr::difference_type n) {
1062  CGAL_assertion( ctnr != NULL);
1063  CGAL_assertion( i != ctnr->end());
1064  typename Ctnr::difference_type j = i - ctnr->begin();
1065  typename Ctnr::difference_type size = ctnr->size();
1066  CGAL_assertion( j >= 0);
1067  CGAL_assertion( size >= 0);
1068  j = non_negative_mod( j + n, size);
1069  CGAL_assertion( j >= 0);
1070  CGAL_assertion( j < size);
1071  i = ctnr->begin() + j;
1072  return *this;
1073 }
1074 #endif // _MSC_VER
1075 // Note: TT, SS, and DD are here for backwards compatibility, they are
1076 // not used.
1077 template < class I, class TT = int, class SS = int, class DD = int>
1079 public:
1080 // TYPES
1081 
1083  typedef I iterator;
1084  typedef std::iterator_traits<iterator> Traits;
1085 
1086  typedef typename Traits::value_type value_type;
1087  typedef std::size_t size_type;
1088  typedef typename Traits::difference_type difference_type;
1089  typedef typename Traits::reference reference;
1090  typedef typename Traits::pointer pointer;
1091 
1092  typedef typename Traits::iterator_category Icategory;
1095 
1096 private:
1100 
1101 public:
1102 // CREATION
1103 
1105 
1106  Circulator_from_iterator( const I& bgn, const I& end)
1107  : m_begin(bgn), m_end(end), current(bgn) {}
1108 
1109  Circulator_from_iterator( const I& bgn, const I& end, const I& cur)
1110  : m_begin(bgn), m_end(end), current(cur) {}
1111 
1112  Circulator_from_iterator( const Self& c, const I& cur)
1113  : m_begin( c.m_begin), m_end( c.m_end), current(cur) {}
1114 
1115 
1116  template <class II, class A1, class A2, class A3>
1117  // Allow construction from Circulator_from_iterator with
1118  // assignment compatible iterator II:
1121  : m_begin( ii.begin()), m_end( ii.end()),
1122  current(ii.current_iterator()) {}
1123 
1124 //
1125 // OPERATIONS
1126 
1127  bool operator==( CGAL_NULL_TYPE p) const {
1129  CGAL_assertion((m_end == m_begin) || (current != m_end));
1130  return m_end == m_begin;
1131  }
1132  bool operator!=( CGAL_NULL_TYPE p) const { return !(*this == p); }
1133  bool operator==( const Self& c) const { return current == c.current;}
1134  bool operator!=( const Self& c) const { return !(*this == c); }
1137  return *current;
1138  }
1141  return &(*current);
1142  }
1145  ++current;
1146  if ( current == m_end)
1147  current = m_begin;
1148  return *this;
1149  }
1151  Self tmp= *this;
1152  ++*this;
1153  return tmp;
1154  }
1157  if ( current == m_begin)
1158  current = m_end;
1159  --current;
1160  return *this;
1161  }
1163  Self tmp = *this;
1164  --*this;
1165  return tmp;
1166  }
1170  difference_type size = m_end - m_begin;
1171  CGAL_assertion( i >= 0);
1172  CGAL_assertion( size >= 0);
1173  i = non_negative_mod( i + n, size);
1174  CGAL_assertion( i >= 0);
1175  CGAL_assertion( i < size);
1176  current = m_begin + i;
1177  return *this;
1178  }
1180  Self tmp = *this;
1181  return tmp += n;
1182  }
1185  Self tmp = *this;
1186  return tmp += -n;
1187  }
1188  difference_type operator-( const Self& i) const {
1189  CGAL_assertion((m_begin == i.m_begin) && (m_end == i.m_end));
1190  return current - i.current;
1191  }
1193  Self tmp = *this;
1194  tmp += n;
1195  return tmp.operator*();
1196  }
1197  iterator begin() const { return m_begin;}
1198  iterator end() const { return m_end;}
1199  iterator current_iterator() const { return current;}
1200  Self min_circulator() const { return Self( m_begin, m_end); }
1201 };
1202 
1203 template < class D, class I, class T, class Size, class Dist> inline
1205 operator+( D n, const
1208  tmp = circ;
1209  return tmp += Dist(n);
1210 }
1211 
1213 
1214 #endif // CGAL_CIRCULATOR_H //
1215 // EOF //
Self operator+(difference_type n) const
Definition: circulator.h:1023
bool operator==(const Self &c) const
Definition: circulator.h:968
Const_circulator_from_container(const Mutable &c)
Definition: circulator.h:951
CTraits::iterator_category iterator_category
Definition: circulator.h:1094
Ic_traits::iterator_category iterator_category
Definition: circulator.h:214
std::iterator_traits< iterator > ITraits
Definition: circulator.h:781
#define CGAL_assertion(EX)
Definition: assertions.h:87
Self operator-(difference_type n) const
Definition: circulator.h:871
Self operator+(difference_type n) const
Definition: circulator.h:866
difference_type operator-(const Self &i) const
Definition: circulator.h:1188
bool operator==(const Self &i) const
Definition: circulator.h:583
Iterator_tag category
Definition: circulator.h:128
Circulator current_circulator() const
Definition: circulator.h:684
Ctnr::reference reference
Definition: circulator.h:776
I_Circulator_traits< ICAT > C_traits
Definition: circulator.h:210
C::difference_type difference_type
Definition: circulator.h:739
Ci_traits::iterator_category circulator_category
Definition: circulator.h:217
const NT & d
bool operator!=(CGAL_NULL_TYPE p) const
Definition: circulator.h:967
Ctnr::const_reference reference
Definition: circulator.h:929
iterator current_iterator() const
Definition: circulator.h:885
Self & operator-=(difference_type n)
Definition: circulator.h:1027
double s
Definition: blastest.C:80
Ctnr::size_type size_type
Definition: circulator.h:778
Self & operator+=(difference_type n)
Definition: circulator.h:626
void Assert_is_at_least_forward_category(const IC &ic)
Definition: circulator.h:333
void Assert_output_category(const I &i)
Definition: circulator.h:257
bool operator==(const Self &c) const
Definition: circulator.h:811
traits::iterator_category ICAT
Definition: circulator.h:209
void Assert_is_at_least_output_category(const I &i)
Definition: circulator.h:327
Self & operator-=(difference_type n)
Definition: circulator.h:640
C::difference_type difference_type
Definition: circulator.h:559
std::iterator_traits< IC >::difference_type iterator_distance(const IC &ic1, const IC &ic2)
Definition: circulator.h:500
std::iterator_traits< C > traits
Definition: circulator.h:208
bool operator==(CGAL_NULL_TYPE p) const
Definition: circulator.h:963
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE ic
std::iterator_traits< const_iterator > ITraits
Definition: circulator.h:934
#define CGAL_CIRC_NULL
Definition: circulator.h:81
Iterator_from_circulator< C, Ref, Ptr > operator+(Dist n, const Iterator_from_circulator< C, Ref, Ptr > &circ)
Definition: circulator.h:689
bool is_empty_range(const IC &ic1, const IC &ic2)
Definition: circulator.h:362
Iterator_from_circulator< C, reference, pointer > iterator
Definition: circulator.h:742
ITraits::iterator_category Icategory
Definition: circulator.h:782
bool operator==(const Self &c) const
Definition: circulator.h:1133
Ctnr::const_iterator const_iterator
Definition: circulator.h:927
bool operator!=(const Self &c) const
Definition: circulator.h:812
C::reference reference
Definition: circulator.h:561
C::difference_type I_circulator_distance(C c, const C &d, Forward_circulator_tag)
Definition: circulator.h:450
bool operator>=(const Self &i) const
Definition: circulator.h:680
Ctnr * container() const
Definition: circulator.h:887
I_Circulator_from_iterator_traits< Icategory > CTraits
Definition: circulator.h:936
Const_circulator_from_container< Ctnr > Self
Definition: circulator.h:924
Self & operator+=(difference_type n)
Definition: circulator.h:1167
C::value_type value_type
Definition: circulator.h:733
iterator begin() const
Definition: circulator.h:1197
C get_min_circulator(C c)
Definition: circulator.h:517
Self operator+(difference_type n) const
Definition: circulator.h:636
void Assert_bidirectional_category(const IC &ic)
Definition: circulator.h:269
bool operator==(CGAL_NULL_TYPE p) const
Definition: circulator.h:1127
Ctnr::iterator iterator
Definition: circulator.h:774
Traits::iterator_category Icategory
Definition: circulator.h:1092
C I_get_min_circulator(C c, Forward_circulator_tag)
Definition: circulator.h:505
bool operator!=(CGAL_NULL_TYPE p) const
Definition: circulator.h:1132
std::iterator_traits< iterator > Traits
Definition: circulator.h:1084
Circulator_or_iterator_tag check_circulator_or_iterator(Circulator_tag)
Definition: circulator.h:373
CTraits::iterator_category iterator_category
Definition: circulator.h:937
Circulator_from_iterator< I, TT, SS, DD > Self
Definition: circulator.h:1082
Iterator_from_circulator< C, const_reference, const_pointer > const_iterator
Definition: circulator.h:744
void I_Has_to_be_at_least(std::input_iterator_tag, std::input_iterator_tag)
Definition: circulator.h:286
pointer operator->() const
Definition: circulator.h:818
Self min_circulator() const
Definition: circulator.h:886
I_Iterator_from_circulator_traits< ICAT > Ic_traits
Definition: circulator.h:213
Self operator-(difference_type n) const
Definition: circulator.h:1184
Self min_circulator() const
Definition: circulator.h:1200
Circulator_traits< C >::category query_circulator_or_iterator(const C &)
Definition: circulator.h:222
Self operator+(difference_type n) const
Definition: circulator.h:1179
bool operator!=(const Self &c) const
Definition: circulator.h:1134
reference operator[](difference_type n) const
Definition: circulator.h:880
void Assert_iterator(const I &i)
Definition: circulator.h:247
#define CGAL_TEMPLATE_NULL
Definition: config.h:126
bool operator<(const Self &i) const
Definition: circulator.h:668
#define CGAL_precondition(EX)
Definition: assertions.h:147
Ctnr::difference_type difference_type
Definition: circulator.h:779
C::size_type I_circulator_size(const C &c, Forward_circulator_tag)
Definition: circulator.h:417
Circulator_from_container< Ctnr > Mutable
Definition: circulator.h:925
Traits::difference_type difference_type
Definition: circulator.h:1088
reference operator*() const
Definition: circulator.h:813
bool operator!=(CGAL_NULL_TYPE p) const
Definition: circulator.h:810
const_iterator end() const
Definition: circulator.h:761
std::iterator_traits< C > I_traits
Definition: circulator.h:545
void Assert_circulator_or_iterator(const IC &ic)
Definition: circulator.h:383
Circulator_from_container(Ctnr *c)
Definition: circulator.h:794
Iterator_from_circulator(const Iterator_from_circulator< CC, CREF, CPTR > &c)
Definition: circulator.h:575
I__traits::iterator_category iterator_category
Definition: circulator.h:556
bool operator!=(const Self &c) const
Definition: circulator.h:969
Self operator-(difference_type n) const
Definition: circulator.h:1028
void Assert_random_access_category(const IC &ic)
Definition: circulator.h:276
difference_type operator-(const Self &c) const
Definition: circulator.h:1032
blockLoc i
Definition: read.cpp:79
Self & operator+=(difference_type n)
Definition: circulator.h:903
reference operator[](difference_type n) const
Definition: circulator.h:1192
Self & operator-=(difference_type n)
Definition: circulator.h:1183
Self & operator-=(difference_type n)
Definition: circulator.h:870
void int int REAL * x
Definition: read.cpp:74
const value_type * const_pointer
Definition: circulator.h:737
const value_type * pointer
Definition: circulator.h:930
Const_circulator_from_container(const Ctnr *c, const_iterator j)
Definition: circulator.h:949
void Assert_forward_category(const IC &ic)
Definition: circulator.h:263
const NT & n
CTraits::iterator_category iterator_category
Definition: circulator.h:784
Ctnr::value_type value_type
Definition: circulator.h:775
Ctnr::difference_type difference_type
Definition: circulator.h:932
I_Circulator_from_iterator_traits< Icategory > CTraits
Definition: circulator.h:783
Self operator-(difference_type n) const
Definition: circulator.h:643
void Assert_is_at_least_random_access_category(const IC &ic)
Definition: circulator.h:345
C_traits::category category
Definition: circulator.h:211
bool operator==(CGAL_NULL_TYPE p) const
Definition: circulator.h:806
C::difference_type circulator_distance(const C &c, const C &d)
Definition: circulator.h:481
const C * anchor() const
Definition: circulator.h:682
void Assert_input_category(const I &i)
Definition: circulator.h:251
Traits::value_type value_type
Definition: circulator.h:1086
I non_negative_mod(I n, U m)
Definition: circulator.h:523
difference_type operator-(const Self &c) const
Definition: circulator.h:875
bool operator>(const Self &i) const
Definition: circulator.h:678
Self & operator=(const Self &c)
Definition: circulator.h:798
void Assert_compile_time_tag(const Tag &, const Derived &b)
Circulator_from_iterator(const I &bgn, const I &end, const I &cur)
Definition: circulator.h:1109
Ptr operator->() const
Definition: circulator.h:595
iterator end() const
Definition: circulator.h:1198
void Assert_is_at_least_input_category(const I &i)
Definition: circulator.h:321
Traits::reference reference
Definition: circulator.h:1089
C::size_type I_min_circulator_size(const C &c)
Definition: circulator.h:403
reference operator[](difference_type n) const
Definition: circulator.h:1037
Ref operator[](difference_type n) const
Definition: circulator.h:663
Circulator_from_iterator(const I &bgn, const I &end)
Definition: circulator.h:1106
Circulator_from_iterator(const Self &c, const I &cur)
Definition: circulator.h:1112
j indices j
Definition: Indexing.h:6
void Assert_is_at_least_bidirectional_category(const IC &ic)
Definition: circulator.h:339
Self & operator=(const Self &c)
Definition: circulator.h:955
Iterator_from_circulator(const C *circ, int n)
Definition: circulator.h:569
#define CGAL_NULL_TYPE
Definition: circulator.h:80
std::iterator_traits< C >::difference_type I_iterator_distance(const C &c1, const C &c2, Circulator_tag)
Definition: circulator.h:488
C::value_type value_type
Definition: circulator.h:558
void match_compile_time_tag(const Base &) const
Definition: circulator.h:233
I_Circulator_from_iterator_traits< ICAT > Ci_traits
Definition: circulator.h:216
Circulator_from_container(Ctnr *c, iterator j)
Definition: circulator.h:795
ITraits::iterator_category Icategory
Definition: circulator.h:935
I_Circulator_from_iterator_traits< Icategory > CTraits
Definition: circulator.h:1093
Circulator_from_iterator(const Circulator_from_iterator< II, A1, A2, A3 > &ii)
Definition: circulator.h:1119
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
bool I_is_empty_range(const C &c1, const C &, Circulator_tag)
Definition: circulator.h:352
#define CGAL_postcondition(EX)
Definition: assertions.h:207
pointer operator->() const
Definition: circulator.h:1139
void Assert_circulator(const C &c)
Definition: circulator.h:243
Ref operator*() const
Definition: circulator.h:590
Iterator_from_circulator< C, Ref, Ptr > Self
Definition: circulator.h:554
iterator current_iterator() const
Definition: circulator.h:1199
I_traits::iterator_category I_Iter_cat
Definition: circulator.h:546
Const_circulator_from_container(const Ctnr *c)
Definition: circulator.h:947
const_iterator current_iterator() const
Definition: circulator.h:1042
Traits::pointer pointer
Definition: circulator.h:1090
bool operator<=(const Self &i) const
Definition: circulator.h:679
const_iterator begin() const
Definition: circulator.h:752
Self & operator+=(difference_type n)
Definition: circulator.h:1061
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
bool operator!=(const Self &i) const
Definition: circulator.h:587
const Ctnr * container() const
Definition: circulator.h:1044
C::size_type size_type
Definition: circulator.h:560
const value_type & const_reference
Definition: circulator.h:735
I_Iterator_from_circulator_traits< I_Iter_cat > I__traits
Definition: circulator.h:547
Circulator_from_container< Ctnr > Self
Definition: circulator.h:772
reference operator*() const
Definition: circulator.h:1135
C::size_type circulator_size(const C &c)
Definition: circulator.h:443
reference operator*() const
Definition: circulator.h:970