Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
SimpleRandomAccessConstRangeFromPoint.h
1
16
17#pragma once
18
32
33#if defined(SimpleRandomAccessConstRangeFromPoint_RECURSES)
34#error Recursive header files inclusion detected in SimpleRandomAccessConstRangeFromPoint.h
35#else // defined(SimpleRandomAccessConstRangeFromPoint_RECURSES)
37#define SimpleRandomAccessConstRangeFromPoint_RECURSES
38
39#if !defined SimpleRandomAccessConstRangeFromPoint_h
41#define SimpleRandomAccessConstRangeFromPoint_h
42
44// Inclusions
45#include "DGtal/base/BasicFunctors.h"
46#include "DGtal/base/Circulator.h"
47#include "DGtal/base/ConstIteratorAdapter.h"
48#include "DGtal/base/CConstBidirectionalRangeFromPoint.h"
49#include "boost/concept_check.hpp"
50#include "boost/iterator/reverse_iterator.hpp"
52
53namespace DGtal
54{
55
56
58 // class SimpleRandomAccessConstRangeFromPoint
60
72 template <typename TConstIterator, typename DistanceFunctor>
73
75 {
76
79
80 // ------------------------- inner types --------------------------------
81
82 public:
83
84
85 typedef typename DistanceFunctor::Point Point;
86
87 typedef TConstIterator ConstIterator;
88 typedef boost::reverse_iterator<ConstIterator> ConstReverseIterator;
89
91 typedef boost::reverse_iterator<ConstCirculator> ConstReverseCirculator;
92
93 // ------------------------- standard services --------------------------------
94
103 SimpleRandomAccessConstRangeFromPoint ( const TConstIterator& itb, const TConstIterator& ite, const DistanceFunctor & aDistance )
104 : myBegin ( itb ), myEnd ( ite ), myDistance ( aDistance ) {}
105
112
119 {
120 if ( this != &other )
121 {
122 myBegin = other.myBegin;
123 myEnd = other.myEnd;
124 myDistance = other.myDistance;
125 }
126
127 return *this;
128 }
129
134
139 bool isValid() const
140 {
141 return true;
142 }
143
144 // ------------------------- display --------------------------------
149 void selfDisplay ( std::ostream & out ) const
150 {
152 out << "[SimpleRandomAccessConstRangeFromPoint]" << std::endl;
153 out << "\t";
154 std::copy ( myBegin, myEnd, std::ostream_iterator<Value> ( out, ", " ) );
155 out << std::endl;
156 }
157
161 std::string className() const
162 {
163 return "SimpleRandomAccessConstRangeFromPoint";
164 }
165
166
167 // ------------------------- private data --------------------------------
168
169 private:
173 TConstIterator myBegin;
177 TConstIterator myEnd;
178
183
184 // ------------------------- iterator services --------------------------------
185
186 public:
187
193 {
194 return ConstIterator ( myBegin );
195 }
196
197
204 {
205 return ConstIterator ( myBegin ) + myDistance ( aPoint );
206 }
207
213 {
214 return ConstIterator ( myEnd );
215 }
216
222 {
223 return ConstReverseIterator ( this->end() );
224 }
225
231 ConstReverseIterator rbegin ( const Point &aPoint ) const
232 {
233 return ConstReverseIterator ( myBegin + myDistance ( aPoint ) + 1 );
234 }
235
236
242 {
243 return ConstReverseIterator ( myBegin );
244 }
245
251 {
252 return ConstCirculator ( this->begin(), this->begin(), this->end() );
253 }
254
259 ConstReverseCirculator rc() const
260 {
261 return ConstReverseCirculator ( this->c() );
262 }
263
264 }; //end class SimpleRandomAccessConstRangeFromPoint
265
266} // namespace DGtal
267
269
270
271#endif // !defined SimpleRandomAccessConstRangeFromPoint_h
272
273#undef SimpleRandomAccessConstRangeFromPoint_RECURSES
274#endif // else defined(SimpleRandomAccessConstRangeFromPoint_RECURSES)
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition Circulator.h:86
ConstReverseIterator rbegin(const Point &aPoint) const
SimpleRandomAccessConstRangeFromPoint(const TConstIterator &itb, const TConstIterator &ite, const DistanceFunctor &aDistance)
SimpleRandomAccessConstRangeFromPoint & operator=(const SimpleRandomAccessConstRangeFromPoint &other)
BOOST_CONCEPT_ASSERT((boost::UnaryFunction< DistanceFunctor, typename DistanceFunctor::Difference, typename DistanceFunctor::Point >))
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator< TConstIterator >))
SimpleRandomAccessConstRangeFromPoint(const SimpleRandomAccessConstRangeFromPoint &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)