DGtal  1.3.beta
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)
36 
37 #define SimpleRandomAccessRangeFromPoint_RECURSES
38 
39 #if !defined SimpleRandomAccessRangeFromPoint_h
40 
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 
52 namespace 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 
121  : myBegin ( other.myBegin ), myEnd ( other.myEnd ),
122  myDistance ( other.myDistance ) {}
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 
234  ConstIterator begin ( const Point &aPoint ) const
235  {
236  return ConstIterator ( myBegin ) + myDistance ( aPoint );
237  }
238 
244  {
245  return Iterator ( myEnd );
246  }
247 
253  {
254  return ConstIterator ( myEnd );
255  }
256 
262  {
263  return OutputIterator ( myBegin );
264  }
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)
DGtal::SimpleRandomAccessRangeFromPoint::OutputIterator
TIterator OutputIterator
Definition: SimpleRandomAccessRangeFromPoint.h:92
DGtal::SimpleRandomAccessRangeFromPoint::selfDisplay
void selfDisplay(std::ostream &out) const
Definition: SimpleRandomAccessRangeFromPoint.h:160
DGtal::SimpleRandomAccessRangeFromPoint::c
Circulator c()
Definition: SimpleRandomAccessRangeFromPoint.h:358
DGtal::Circulator
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:85
DGtal::SimpleRandomAccessRangeFromPoint::ReverseCirculator
std::reverse_iterator< Circulator > ReverseCirculator
Definition: SimpleRandomAccessRangeFromPoint.h:96
DGtal::SimpleRandomAccessRangeFromPoint::begin
Iterator begin()
Definition: SimpleRandomAccessRangeFromPoint.h:203
DGtal::SimpleRandomAccessRangeFromPoint::Point
DistanceFunctor::Point Point
Definition: SimpleRandomAccessRangeFromPoint.h:84
DGtal::SimpleRandomAccessRangeFromPoint::routputIterator
ReverseOutputIterator routputIterator()
Definition: SimpleRandomAccessRangeFromPoint.h:280
DGtal::SimpleRandomAccessRangeFromPoint::rend
ReverseIterator rend()
Definition: SimpleRandomAccessRangeFromPoint.h:319
DGtal::SimpleRandomAccessRangeFromPoint::Iterator
TIterator Iterator
Definition: SimpleRandomAccessRangeFromPoint.h:86
aPoint
const Point aPoint(3, 4)
DGtal::SimpleRandomAccessRangeFromPoint::rc
ReverseCirculator rc()
Definition: SimpleRandomAccessRangeFromPoint.h:367
DGtal::SimpleRandomAccessRangeFromPoint::end
Iterator end()
Definition: SimpleRandomAccessRangeFromPoint.h:243
DGtal::SimpleRandomAccessRangeFromPoint::SimpleRandomAccessRangeFromPoint
SimpleRandomAccessRangeFromPoint(const TIterator &itb, const TIterator &ite, const DistanceFunctor &aDistance)
Definition: SimpleRandomAccessRangeFromPoint.h:111
DGtal::SimpleRandomAccessRangeFromPoint::outputIterator
OutputIterator outputIterator(const Point &aPoint)
Definition: SimpleRandomAccessRangeFromPoint.h:271
DGtal::SimpleRandomAccessRangeFromPoint::begin
ConstIterator begin(const Point &aPoint) const
Definition: SimpleRandomAccessRangeFromPoint.h:234
DGtal::SimpleRandomAccessRangeFromPoint::className
std::string className() const
Definition: SimpleRandomAccessRangeFromPoint.h:172
DGtal::SimpleRandomAccessRangeFromPoint::Circulator
DGtal::Circulator< Iterator > Circulator
Definition: SimpleRandomAccessRangeFromPoint.h:95
DGtal::SimpleRandomAccessRangeFromPoint::myEnd
TIterator myEnd
Definition: SimpleRandomAccessRangeFromPoint.h:188
DGtal::SimpleRandomAccessRangeFromPoint::rbegin
ReverseIterator rbegin()
Definition: SimpleRandomAccessRangeFromPoint.h:299
DGtal::SimpleRandomAccessRangeFromPoint::ReverseOutputIterator
std::reverse_iterator< Iterator > ReverseOutputIterator
Definition: SimpleRandomAccessRangeFromPoint.h:93
DGtal::SimpleRandomAccessRangeFromPoint::c
ConstCirculator c() const
Definition: SimpleRandomAccessRangeFromPoint.h:376
DGtal::SimpleRandomAccessRangeFromPoint::rend
ConstReverseIterator rend() const
Definition: SimpleRandomAccessRangeFromPoint.h:349
DGtal::SimpleRandomAccessRangeFromPoint::ReverseIterator
std::reverse_iterator< Iterator > ReverseIterator
Definition: SimpleRandomAccessRangeFromPoint.h:89
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::SimpleRandomAccessRangeFromPoint::routputIterator
ReverseOutputIterator routputIterator(const Point &aPoint)
Definition: SimpleRandomAccessRangeFromPoint.h:290
DGtal::SimpleRandomAccessRangeFromPoint
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
Definition: SimpleRandomAccessRangeFromPoint.h:73
DGtal::SimpleRandomAccessRangeFromPoint::ConstCirculator
DGtal::Circulator< ConstIterator > ConstCirculator
Definition: SimpleRandomAccessRangeFromPoint.h:98
DGtal::SimpleRandomAccessRangeFromPoint::ConstReverseIterator
std::reverse_iterator< ConstIterator > ConstReverseIterator
Definition: SimpleRandomAccessRangeFromPoint.h:90
DGtal::SimpleRandomAccessRangeFromPoint::rc
ConstReverseCirculator rc() const
Definition: SimpleRandomAccessRangeFromPoint.h:385
DGtal::SimpleRandomAccessRangeFromPoint::rbegin
ReverseIterator rbegin(const Point &aPoint)
Definition: SimpleRandomAccessRangeFromPoint.h:309
boost::RandomAccessIterator
Go to http://www.sgi.com/tech/stl/RandomAccessIterator.html.
Definition: Boost.dox:44
DGtal::SimpleRandomAccessRangeFromPoint::~SimpleRandomAccessRangeFromPoint
~SimpleRandomAccessRangeFromPoint()
Definition: SimpleRandomAccessRangeFromPoint.h:144
DGtal::SimpleRandomAccessRangeFromPoint::myDistance
DistanceFunctor myDistance
Definition: SimpleRandomAccessRangeFromPoint.h:193
DGtal::SimpleRandomAccessRangeFromPoint::isValid
bool isValid() const
Definition: SimpleRandomAccessRangeFromPoint.h:150
boost::UnaryFunction
Go to http://www.sgi.com/tech/stl/UnaryFunction.html.
Definition: Boost.dox:73
DGtal::SimpleRandomAccessRangeFromPoint::rbegin
ConstReverseIterator rbegin(const Point &aPoint) const
Definition: SimpleRandomAccessRangeFromPoint.h:339
DGtal::SimpleRandomAccessRangeFromPoint::end
ConstIterator end() const
Definition: SimpleRandomAccessRangeFromPoint.h:252
DGtal::SimpleRandomAccessRangeFromPoint::begin
ConstIterator begin() const
Definition: SimpleRandomAccessRangeFromPoint.h:223
DGtal::SimpleRandomAccessRangeFromPoint::SimpleRandomAccessRangeFromPoint
SimpleRandomAccessRangeFromPoint(const SimpleRandomAccessRangeFromPoint &other)
Definition: SimpleRandomAccessRangeFromPoint.h:120
DGtal::SimpleRandomAccessRangeFromPoint::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator< TIterator >))
DGtal::SimpleRandomAccessRangeFromPoint::rbegin
ConstReverseIterator rbegin() const
Definition: SimpleRandomAccessRangeFromPoint.h:329
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::SimpleRandomAccessRangeFromPoint::operator=
SimpleRandomAccessRangeFromPoint & operator=(const SimpleRandomAccessRangeFromPoint &other)
Definition: SimpleRandomAccessRangeFromPoint.h:129
DGtal::SimpleRandomAccessRangeFromPoint::ConstIterator
TConstIterator ConstIterator
Definition: SimpleRandomAccessRangeFromPoint.h:87
DGtal::IteratorCirculatorTraits::Value
IC::value_type Value
Definition: IteratorCirculatorTraits.h:303
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::SimpleRandomAccessRangeFromPoint::ConstReverseCirculator
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
Definition: SimpleRandomAccessRangeFromPoint.h:99
DGtal::SimpleRandomAccessRangeFromPoint::begin
Iterator begin(const Point &aPoint)
Definition: SimpleRandomAccessRangeFromPoint.h:214
DGtal::SimpleRandomAccessRangeFromPoint::myBegin
TIterator myBegin
Definition: SimpleRandomAccessRangeFromPoint.h:184
DGtal::SimpleRandomAccessRangeFromPoint::outputIterator
OutputIterator outputIterator()
Definition: SimpleRandomAccessRangeFromPoint.h:261