Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_step_adaptor.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1997, 1998, 1999, 2000 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/N_step_adaptor.h
37 // package : STL_Extension (2.21)
38 // chapter : $CGAL_Chapter: STL Extensions for CGAL $
39 // source : stl_extension.fw
40 // revision : $Revision: 1.1.1.1 $
41 // revision_date : $Date: 2001/07/05 22:17:47 $
42 // author(s) : Michael Hoffmann
43 // Lutz Kettner
44 //
45 //
46 // An iterator/circulator adaptor doing n-steps per increment.
47 // coordinator : ?
48 // email : contact@cgal.org
49 // www : http://www.cgal.org
50 //
51 // ======================================================================
52 
53 #ifndef CGAL_N_STEP_ADAPTOR_H
54 #define CGAL_N_STEP_ADAPTOR_H 1
55 #include <CGAL/circulator.h>
56 
58 
59 #if defined(CGAL_CFG_NO_ITERATOR_TRAITS) && \
60 !defined(CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT)
61 template < class I, int N, class Ref, class Ptr,
62  class Val, class Dist, class Ctg>
63 #else
64 template < class I,
65  int N,
66  class Ref = typename std::iterator_traits<I>::reference,
67  class Ptr = typename std::iterator_traits<I>::pointer,
68  class Val = typename std::iterator_traits<I>::value_type,
69  class Dist = typename std::iterator_traits<I>::difference_type,
70  class Ctg = typename std::iterator_traits<I>::iterator_category>
71 #endif
73 protected:
74  I nt; // The internal iterator.
75 public:
76  typedef I Iterator;
78  typedef Ctg iterator_category;
79  typedef Val value_type;
80  typedef Dist difference_type;
81 #ifdef CGAL_CFG_NO_ITERATOR_TRAITS
82  typedef Ref reference;
83  typedef Ptr pointer;
84 #else
85  typedef typename std::iterator_traits<I>::reference reference;
86  typedef typename std::iterator_traits<I>::pointer pointer;
87 #endif
88  // Special for circulators.
90  typedef typename C_S_Traits::size_type size_type;
91 
92  // CREATION
93  // --------
94 
97 
98  template <class II>
100  : nt( j.current_iterator()) {}
101 
102  // OPERATIONS Forward Category
103  // ---------------------------
104 
105  // Circulator stuff.
106  typedef I Circulator;
107  Circulator current_circulator() const { return nt;}
108 
109  Iterator current_iterator() const { return nt;}
110  bool operator==( CGAL_NULL_TYPE p) const {
111  CGAL_assertion( p == 0);
112  return ( nt == 0);
113  }
114  bool operator!=( CGAL_NULL_TYPE p) const { return !(*this == p); }
115  bool operator==( const Self& i) const { return ( nt == i.nt); }
116  bool operator!=( const Self& i) const { return !(*this == i); }
117  Ref operator*() const { return *nt; }
118  Ptr operator->() const { return nt.operator->(); }
120  std::advance( nt, N);
121  return *this;
122  }
124  Self tmp = *this;
125  ++*this;
126  return tmp;
127  }
128 
129  // OPERATIONS Bidirectional Category
130  // ---------------------------------
131 
133  std::advance( nt, -N);
134  return *this;
135  }
137  Self tmp = *this;
138  --*this;
139  return tmp;
140  }
141 
142  // OPERATIONS Random Access Category
143  // ---------------------------------
144 
145  Self min_circulator() const { return Self( nt.min_circulator()); }
147  nt += difference_type(N * n);
148  return *this;
149  }
151  Self tmp = *this;
152  tmp.nt += difference_type(N * n);
153  return tmp;
154  }
155 #ifdef CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES
156  friend inline
157  Self
159  i = i + n;
160  return i;
161  }
162 #endif // CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES //
164  return operator+=( -n);
165  }
167  Self tmp = *this;
168  return tmp += -n;
169  }
170  difference_type operator-( const Self& i) const { return (nt-i.nt)/N;}
172  Self tmp = *this;
173  tmp += n;
174  return tmp.operator*();
175  }
176  bool operator<( const Self& i) const { return ( nt < i.nt); }
177  bool operator>( const Self& i) const { return i < *this; }
178  bool operator<=( const Self& i) const { return !(i < *this); }
179  bool operator>=( const Self& i) const { return !(*this < i); }
180 #ifdef CGAL_CFG_NO_ITERATOR_TRAITS
181 #ifndef CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT
182  friend inline iterator_category
183  iterator_category( const Self&) { return iterator_category(); }
184  friend inline value_type*
185  value_type( const Self&) { return (value_type*)(0); }
186  friend inline difference_type*
187  distance_type( const Self&) { return (difference_type*)(0); }
188  typedef _Circulator_traits<iterator_category> C_Traits;
189  typedef typename C_Traits::category category;
190  friend inline category
191  query_circulator_or_iterator( const Self&) { return category(); }
192 #endif // CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT
193 #endif // CGAL_CFG_NO_ITERATOR_TRAITS //
194 };
195 #ifndef CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES
196 template < class I, int N, class Ref, class Ptr,
197  class Val, class Dist, class Ctg>
198 inline
201 { return i += n; }
202 #endif // CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES //
203 
205 #endif // CGAL_N_STEP_ADAPTOR_H //
206 // EOF //
Ptr operator->() const
#define CGAL_assertion(EX)
Definition: assertions.h:87
bool operator!=(CGAL_NULL_TYPE p) const
bool operator<=(const Self &i) const
std::iterator_traits< I >::reference reference
bool operator!=(const Self &i) const
Self operator--(int)
bool operator==(CGAL_NULL_TYPE p) const
Self & operator--()
bool operator==(const Self &i) const
bool operator>(const Self &i) const
Self operator+(difference_type n) const
Iterator_from_circulator< C, Ref, Ptr > operator+(Dist n, const Iterator_from_circulator< C, Ref, Ptr > &circ)
Definition: circulator.h:689
std::iterator_traits< I >::pointer pointer
Self & operator+=(difference_type n)
Circulator current_circulator() const
Self & operator++()
Circulator_traits< C >::category query_circulator_or_iterator(const C &)
Definition: circulator.h:222
bool operator<(const Self &i) const
N_step_adaptor< I, N, Ref, Ptr, Val, Dist, Ctg > Self
Self operator++(int)
difference_type operator-(const Self &i) const
blockLoc i
Definition: read.cpp:79
const NT & n
bool operator>=(const Self &i) const
I_Circulator_size_traits< iterator_category, I > C_S_Traits
Self operator-(difference_type n) const
Self & operator-=(difference_type n)
j indices j
Definition: Indexing.h:6
Ref operator*() const
#define CGAL_NULL_TYPE
Definition: circulator.h:80
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
N_step_adaptor(const N_step_adaptor< II, N > &j)
C_S_Traits::size_type size_type
Iterator current_iterator() const
Ref operator[](difference_type n) const
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
N_step_adaptor(Iterator j)
Self min_circulator() const