DGtal 1.4.0
Loading...
Searching...
No Matches
SimpleRandomAccessConstRangeFromPoint.h
1
17#pragma once
18
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"
51
52namespace DGtal
53{
54
55
57 // class SimpleRandomAccessConstRangeFromPoint
59
71 template <typename TConstIterator, typename DistanceFunctor>
72
74 {
75
78
79 // ------------------------- inner types --------------------------------
80
81 public:
82
83
84 typedef typename DistanceFunctor::Point Point;
85
86 typedef TConstIterator ConstIterator;
87 typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
88
90 typedef std::reverse_iterator<ConstCirculator> ConstReverseCirculator;
91
92 // ------------------------- standard services --------------------------------
93
102 SimpleRandomAccessConstRangeFromPoint ( const TConstIterator& itb, const TConstIterator& ite, const DistanceFunctor & aDistance )
103 : myBegin ( itb ), myEnd ( ite ), myDistance ( aDistance ) {}
104
111
118 {
119 if ( this != &other )
120 {
121 myBegin = other.myBegin;
122 myEnd = other.myEnd;
123 myDistance = other.myDistance;
124 }
125
126 return *this;
127 }
128
133
138 bool isValid() const
139 {
140 return true;
141 }
142
143 // ------------------------- display --------------------------------
148 void selfDisplay ( std::ostream & out ) const
149 {
151 out << "[SimpleRandomAccessConstRangeFromPoint]" << std::endl;
152 out << "\t";
153 std::copy ( myBegin, myEnd, std::ostream_iterator<Value> ( out, ", " ) );
154 out << std::endl;
155 }
156
160 std::string className() const
161 {
162 return "SimpleRandomAccessConstRangeFromPoint";
163 }
164
165
166 // ------------------------- private data --------------------------------
167
168 private:
172 TConstIterator myBegin;
176 TConstIterator myEnd;
177
181 DistanceFunctor myDistance;
182
183 // ------------------------- iterator services --------------------------------
184
185 public:
186
192 {
193 return ConstIterator ( myBegin );
194 }
195
196
203 {
204 return ConstIterator ( myBegin ) + myDistance ( aPoint );
205 }
206
212 {
213 return ConstIterator ( myEnd );
214 }
215
221 {
222 return ConstReverseIterator ( this->end() );
223 }
224
230 ConstReverseIterator rbegin ( const Point &aPoint ) const
231 {
232 return ConstReverseIterator ( myBegin + myDistance ( aPoint ) + 1 );
233 }
234
235
241 {
242 return ConstReverseIterator ( myBegin );
243 }
244
250 {
251 return ConstCirculator ( this->begin(), this->begin(), this->end() );
252 }
253
258 ConstReverseCirculator rc() const
259 {
260 return ConstReverseCirculator ( this->c() );
261 }
262
263 }; //end class SimpleRandomAccessConstRangeFromPoint
264
265} // namespace DGtal
266
268
269
270#endif // !defined SimpleRandomAccessConstRangeFromPoint_h
271
272#undef SimpleRandomAccessConstRangeFromPoint_RECURSES
273#endif // else defined(SimpleRandomAccessConstRangeFromPoint_RECURSES)
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition Circulator.h:86
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
ConstReverseIterator rbegin(const Point &aPoint) const
SimpleRandomAccessConstRangeFromPoint(const TConstIterator &itb, const TConstIterator &ite, const DistanceFunctor &aDistance)
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
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)