DGtal 1.4.2
Loading...
Searching...
No Matches
SimpleRandomAccessRangeFromPoint.h
1
17#pragma once
18
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"
51
52namespace DGtal
53{
54
55
57 // class SimpleRandomAccessRangeFromPoint
59
71 template <typename TConstIterator, typename TIterator, typename DistanceFunctor>
72
74 {
75
79
80 // ------------------------- inner types --------------------------------
81
82 public:
83
84 typedef typename DistanceFunctor::Point Point;
85
86 typedef TIterator Iterator;
87 typedef TConstIterator ConstIterator;
88
89 typedef std::reverse_iterator<Iterator> ReverseIterator;
90 typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
91
92 typedef TIterator OutputIterator;
93 typedef std::reverse_iterator<Iterator> ReverseOutputIterator;
94
96 typedef std::reverse_iterator<Circulator> ReverseCirculator;
97
99 typedef std::reverse_iterator<ConstCirculator> ConstReverseCirculator;
100
101 // ------------------------- standard services --------------------------------
102
111 SimpleRandomAccessRangeFromPoint ( const TIterator& itb,
112 const TIterator& ite,
113 const DistanceFunctor & aDistance )
114 : myBegin ( itb ), myEnd ( ite ), myDistance ( aDistance ) {}
115
123
130 {
131 if ( this != &other )
132 {
133 myBegin = other.myBegin;
134 myEnd = other.myEnd;
135 myDistance = other.myDistance;
136 }
137
138 return *this;
139 }
140
145
150 bool isValid() const
151 {
152 return true;
153 }
154
155 // ------------------------- display --------------------------------
160 void selfDisplay ( std::ostream & out ) const
161 {
163 out << "[SimpleRandomAccessRangeFromPoint]" << std::endl;
164 out << "\t";
165 std::copy ( myBegin, myEnd, std::ostream_iterator<Value> ( out, ", " ) );
166 out << std::endl;
167 }
168
172 std::string className() const
173 {
174 return "SimpleRandomAccessRangeFromPoint";
175 }
176
177
178 // ------------------------- private data --------------------------------
179
180 private:
184 TIterator myBegin;
188 TIterator myEnd;
189
193 DistanceFunctor myDistance;
194
195 // ------------------------- iterator services --------------------------------
196
197 public:
198
204 {
205 return Iterator ( myBegin );
206 }
207
208
215 {
216 return Iterator ( myBegin ) + myDistance ( aPoint );
217 }
218
224 {
225 return ConstIterator ( myBegin );
226 }
227
228
235 {
236 return ConstIterator ( myBegin ) + myDistance ( aPoint );
237 }
238
244 {
245 return Iterator ( myEnd );
246 }
247
253 {
254 return ConstIterator ( myEnd );
255 }
256
265
272 {
273 return OutputIterator ( myBegin ) + myDistance ( aPoint ) ;
274 }
275
281 {
282 return ReverseOutputIterator ( this->end() );
283 }
284
290 ReverseOutputIterator routputIterator ( const Point &aPoint )
291 {
292 return ReverseOutputIterator ( myBegin + myDistance ( aPoint ) + 1 ) ;
293 }
294
300 {
301 return ReverseIterator ( this->end() );
302 }
303
309 ReverseIterator rbegin ( const Point &aPoint )
310 {
311 return ReverseIterator ( myBegin + myDistance ( aPoint ) + 1 );
312 }
313
314
320 {
321 return ReverseIterator ( myBegin );
322 }
323
324
330 {
331 return ConstReverseIterator ( this->end() );
332 }
333
339 ConstReverseIterator rbegin ( const Point &aPoint ) const
340 {
341 return ConstReverseIterator ( myBegin + myDistance ( aPoint ) + 1 );
342 }
343
344
350 {
351 return ConstReverseIterator ( myBegin );
352 }
353
359 {
360 return Circulator ( this->begin(), this->begin(), this->end() );
361 }
362
367 ReverseCirculator rc()
368 {
369 return ReverseCirculator ( this->c() );
370 }
371
376 ConstCirculator c() const
377 {
378 return ConstCirculator ( this->begin(), this->begin(), this->end() );
379 }
380
385 ConstReverseCirculator rc() const
386 {
387 return ConstReverseCirculator ( this->c() );
388 }
389
390 }; //end class SimpleRandomAccessRangeFromPoint
391
392} // namespace DGtal
393
395
396
397#endif // !defined SimpleRandomAccessRangeFromPoint_h
398
399#undef SimpleRandomAccessRangeFromPoint_RECURSES
400#endif // else defined(SimpleRandomAccessRangeFromPoint_RECURSES)
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition Circulator.h:86
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
BOOST_CONCEPT_ASSERT((boost::UnaryFunction< DistanceFunctor, typename DistanceFunctor::Difference, typename DistanceFunctor::Point >))
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator< TConstIterator >))
std::reverse_iterator< Iterator > ReverseOutputIterator
ConstReverseIterator rbegin(const Point &aPoint) const
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
ConstIterator begin(const Point &aPoint) const
std::reverse_iterator< Circulator > ReverseCirculator
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)
std::reverse_iterator< ConstIterator > ConstReverseIterator
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)