Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
SimpleRandomAccessRangeFromPoint.h
1
16
17#pragma once
18
32
33#if defined(SimpleRandomAccessRangeFromPoint_RECURSES)
34#error Recursive header files inclusion detected in SimpleRandomAccessRangeFromPoint.h
35#else // defined(SimpleRandomAccessRangeFromPoint_RECURSES)
37#define SimpleRandomAccessRangeFromPoint_RECURSES
38
39#if !defined SimpleRandomAccessRangeFromPoint_h
41#define SimpleRandomAccessRangeFromPoint_h
42
44// Inclusions
45#include "DGtal/base/BasicFunctors.h"
46#include "DGtal/base/Circulator.h"
47#include "DGtal/base/IteratorAdapter.h"
48#include "DGtal/base/CBidirectionalRangeFromPoint.h"
49#include "boost/concept_check.hpp"
50#include "boost/iterator/reverse_iterator.hpp"
52
53namespace DGtal
54{
55
56
58 // class SimpleRandomAccessRangeFromPoint
60
72 template <typename TConstIterator, typename TIterator, typename DistanceFunctor>
73
75 {
76
80
81 // ------------------------- inner types --------------------------------
82
83 public:
84
85 typedef typename DistanceFunctor::Point Point;
86
87 typedef TIterator Iterator;
88 typedef TConstIterator ConstIterator;
89
90 typedef boost::reverse_iterator<Iterator> ReverseIterator;
91 typedef boost::reverse_iterator<ConstIterator> ConstReverseIterator;
92
93 typedef TIterator OutputIterator;
94 typedef boost::reverse_iterator<Iterator> ReverseOutputIterator;
95
97 typedef boost::reverse_iterator<Circulator> ReverseCirculator;
98
100 typedef boost::reverse_iterator<ConstCirculator> ConstReverseCirculator;
101
102 // ------------------------- standard services --------------------------------
103
112 SimpleRandomAccessRangeFromPoint ( const TIterator& itb,
113 const TIterator& ite,
114 const DistanceFunctor & aDistance )
115 : myBegin ( itb ), myEnd ( ite ), myDistance ( aDistance ) {}
116
124
131 {
132 if ( this != &other )
133 {
134 myBegin = other.myBegin;
135 myEnd = other.myEnd;
136 myDistance = other.myDistance;
137 }
138
139 return *this;
140 }
141
146
151 bool isValid() const
152 {
153 return true;
154 }
155
156 // ------------------------- display --------------------------------
161 void selfDisplay ( std::ostream & out ) const
162 {
164 out << "[SimpleRandomAccessRangeFromPoint]" << std::endl;
165 out << "\t";
166 std::copy ( myBegin, myEnd, std::ostream_iterator<Value> ( out, ", " ) );
167 out << std::endl;
168 }
169
173 std::string className() const
174 {
175 return "SimpleRandomAccessRangeFromPoint";
176 }
177
178
179 // ------------------------- private data --------------------------------
180
181 private:
185 TIterator myBegin;
189 TIterator myEnd;
190
195
196 // ------------------------- iterator services --------------------------------
197
198 public:
199
205 {
206 return Iterator ( myBegin );
207 }
208
209
216 {
217 return Iterator ( myBegin ) + myDistance ( aPoint );
218 }
219
225 {
226 return ConstIterator ( myBegin );
227 }
228
229
236 {
237 return ConstIterator ( myBegin ) + myDistance ( aPoint );
238 }
239
245 {
246 return Iterator ( myEnd );
247 }
248
254 {
255 return ConstIterator ( myEnd );
256 }
257
266
273 {
274 return OutputIterator ( myBegin ) + myDistance ( aPoint ) ;
275 }
276
282 {
283 return ReverseOutputIterator ( this->end() );
284 }
285
291 ReverseOutputIterator routputIterator ( const Point &aPoint )
292 {
293 return ReverseOutputIterator ( myBegin + myDistance ( aPoint ) + 1 ) ;
294 }
295
301 {
302 return ReverseIterator ( this->end() );
303 }
304
310 ReverseIterator rbegin ( const Point &aPoint )
311 {
312 return ReverseIterator ( myBegin + myDistance ( aPoint ) + 1 );
313 }
314
315
321 {
322 return ReverseIterator ( myBegin );
323 }
324
325
331 {
332 return ConstReverseIterator ( this->end() );
333 }
334
340 ConstReverseIterator rbegin ( const Point &aPoint ) const
341 {
342 return ConstReverseIterator ( myBegin + myDistance ( aPoint ) + 1 );
343 }
344
345
351 {
352 return ConstReverseIterator ( myBegin );
353 }
354
360 {
361 return Circulator ( this->begin(), this->begin(), this->end() );
362 }
363
368 ReverseCirculator rc()
369 {
370 return ReverseCirculator ( this->c() );
371 }
372
377 ConstCirculator c() const
378 {
379 return ConstCirculator ( this->begin(), this->begin(), this->end() );
380 }
381
386 ConstReverseCirculator rc() const
387 {
388 return ConstReverseCirculator ( this->c() );
389 }
390
391 }; //end class SimpleRandomAccessRangeFromPoint
392
393} // namespace DGtal
394
396
397
398#endif // !defined SimpleRandomAccessRangeFromPoint_h
399
400#undef SimpleRandomAccessRangeFromPoint_RECURSES
401#endif // else defined(SimpleRandomAccessRangeFromPoint_RECURSES)
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition Circulator.h:86
BOOST_CONCEPT_ASSERT((boost::UnaryFunction< DistanceFunctor, typename DistanceFunctor::Difference, typename DistanceFunctor::Point >))
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator< TConstIterator >))
ConstReverseIterator rbegin(const Point &aPoint) const
ConstIterator begin(const Point &aPoint) const
SimpleRandomAccessRangeFromPoint(const SimpleRandomAccessRangeFromPoint &other)
ReverseOutputIterator routputIterator(const Point &aPoint)
SimpleRandomAccessRangeFromPoint(const TIterator &itb, const TIterator &ite, const DistanceFunctor &aDistance)
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator< TIterator >))
SimpleRandomAccessRangeFromPoint & operator=(const SimpleRandomAccessRangeFromPoint &other)
DGtal is the top-level namespace which contains all DGtal functions and types.
Go to http://www.sgi.com/tech/stl/RandomAccessIterator.html.
Definition Boost.dox:44
Go to http://www.sgi.com/tech/stl/UnaryFunction.html.
Definition Boost.dox:73
const Point aPoint(3, 4)