DGtal  1.3.beta
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)
36 
37 #define SimpleRandomAccessConstRangeFromPoint_RECURSES
38 
39 #if !defined SimpleRandomAccessConstRangeFromPoint_h
40 
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 
52 namespace 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 
110  : myBegin ( other.myBegin ), myEnd ( other.myEnd ), myDistance ( other.myDistance ) {}
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 
202  ConstIterator begin ( const Point &aPoint ) const
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)
DGtal::SimpleRandomAccessConstRangeFromPoint::rbegin
ConstReverseIterator rbegin(const Point &aPoint) const
Definition: SimpleRandomAccessConstRangeFromPoint.h:230
DGtal::SimpleRandomAccessConstRangeFromPoint::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator< TConstIterator >))
DGtal::Circulator
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:85
DGtal::SimpleRandomAccessConstRangeFromPoint
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Definition: SimpleRandomAccessConstRangeFromPoint.h:73
DGtal::SimpleRandomAccessConstRangeFromPoint::rend
ConstReverseIterator rend() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:240
DGtal::SimpleRandomAccessConstRangeFromPoint::ConstIterator
TConstIterator ConstIterator
Definition: SimpleRandomAccessConstRangeFromPoint.h:86
DGtal::SimpleRandomAccessConstRangeFromPoint::isValid
bool isValid() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:138
aPoint
const Point aPoint(3, 4)
DGtal::SimpleRandomAccessConstRangeFromPoint::begin
ConstIterator begin() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:191
DGtal::SimpleRandomAccessConstRangeFromPoint::SimpleRandomAccessConstRangeFromPoint
SimpleRandomAccessConstRangeFromPoint(const TConstIterator &itb, const TConstIterator &ite, const DistanceFunctor &aDistance)
Definition: SimpleRandomAccessConstRangeFromPoint.h:102
DGtal::SimpleRandomAccessConstRangeFromPoint::ConstReverseIterator
std::reverse_iterator< ConstIterator > ConstReverseIterator
Definition: SimpleRandomAccessConstRangeFromPoint.h:87
DGtal::SimpleRandomAccessConstRangeFromPoint::selfDisplay
void selfDisplay(std::ostream &out) const
Definition: SimpleRandomAccessConstRangeFromPoint.h:148
DGtal::SimpleRandomAccessConstRangeFromPoint::ConstCirculator
Circulator< ConstIterator > ConstCirculator
Definition: SimpleRandomAccessConstRangeFromPoint.h:89
DGtal::SimpleRandomAccessConstRangeFromPoint::myEnd
TConstIterator myEnd
Definition: SimpleRandomAccessConstRangeFromPoint.h:176
DGtal::SimpleRandomAccessConstRangeFromPoint::className
std::string className() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:160
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::SimpleRandomAccessConstRangeFromPoint::SimpleRandomAccessConstRangeFromPoint
SimpleRandomAccessConstRangeFromPoint(const SimpleRandomAccessConstRangeFromPoint &other)
Definition: SimpleRandomAccessConstRangeFromPoint.h:109
DGtal::SimpleRandomAccessConstRangeFromPoint::rbegin
ConstReverseIterator rbegin() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:220
DGtal::SimpleRandomAccessConstRangeFromPoint::operator=
SimpleRandomAccessConstRangeFromPoint & operator=(const SimpleRandomAccessConstRangeFromPoint &other)
Definition: SimpleRandomAccessConstRangeFromPoint.h:117
DGtal::SimpleRandomAccessConstRangeFromPoint::begin
ConstIterator begin(const Point &aPoint) const
Definition: SimpleRandomAccessConstRangeFromPoint.h:202
DGtal::SimpleRandomAccessConstRangeFromPoint::myBegin
TConstIterator myBegin
Definition: SimpleRandomAccessConstRangeFromPoint.h:172
DGtal::SimpleRandomAccessConstRangeFromPoint::c
ConstCirculator c() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:249
boost::RandomAccessIterator
Go to http://www.sgi.com/tech/stl/RandomAccessIterator.html.
Definition: Boost.dox:44
boost::UnaryFunction
Go to http://www.sgi.com/tech/stl/UnaryFunction.html.
Definition: Boost.dox:73
DGtal::SimpleRandomAccessConstRangeFromPoint::rc
ConstReverseCirculator rc() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:258
DGtal::SimpleRandomAccessConstRangeFromPoint::ConstReverseCirculator
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
Definition: SimpleRandomAccessConstRangeFromPoint.h:90
DGtal::SimpleRandomAccessConstRangeFromPoint::myDistance
DistanceFunctor myDistance
Definition: SimpleRandomAccessConstRangeFromPoint.h:181
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::SimpleRandomAccessConstRangeFromPoint::Point
DistanceFunctor::Point Point
Definition: SimpleRandomAccessConstRangeFromPoint.h:84
DGtal::IteratorCirculatorTraits::Value
IC::value_type Value
Definition: IteratorCirculatorTraits.h:303
DGtal::SimpleRandomAccessConstRangeFromPoint::end
ConstIterator end() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:211
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::SimpleRandomAccessConstRangeFromPoint::~SimpleRandomAccessConstRangeFromPoint
~SimpleRandomAccessConstRangeFromPoint()
Definition: SimpleRandomAccessConstRangeFromPoint.h:132