DGtal  1.1.0
SimpleConstRange.h
1 
17 #pragma once
18 
33 #if defined(SimpleConstRange_RECURSES)
34 #error Recursive header files inclusion detected in SimpleConstRange.h
35 #else // defined(SimpleConstRange_RECURSES)
36 
37 #define SimpleConstRange_RECURSES
38 
39 #if !defined SimpleConstRange_h
40 
41 #define SimpleConstRange_h
42 
44 // Inclusions
45 #include <iterator>
46 #include <iostream>
47 #include "DGtal/base/BasicFunctors.h"
48 #include "DGtal/base/Circulator.h"
49 #include "DGtal/base/ConstIteratorAdapter.h"
50 #include "boost/concept_check.hpp"
52 
53 namespace DGtal
54 {
55 
56 
58  // class SimpleConstRange
60 
71  template <typename TConstIterator>
73  {
74 
76 
77  // ------------------------- inner types --------------------------------
78  public:
79 
80  typedef TConstIterator ConstIterator;
81  typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
82 
84  typedef std::reverse_iterator<ConstCirculator> ConstReverseCirculator;
85 
86  // ------------------------- standard services --------------------------------
87 
95  SimpleConstRange(const TConstIterator& itb, const TConstIterator& ite)
96  : myBegin(itb), myEnd(ite) {}
97 
103  : myBegin(other.myBegin), myEnd(other.myEnd) {}
104 
111  {
112  if ( this != &other )
113  {
114  myBegin = other.myBegin;
115  myEnd = other.myEnd;
116  }
117  return *this;
118  }
119 
124 
129  bool isValid() const { return true; }
130 
131  // ------------------------- display --------------------------------
136  void selfDisplay ( std::ostream & out ) const
137  {
139  out << "[SimpleConstRange]" << std::endl;
140  out << "\t";
141  std::copy( myBegin, myEnd, std::ostream_iterator<Value>(out, ", ") );
142  out << std::endl;
143  }
144 
148  std::string className() const
149  {
150  return "SimpleConstRange";
151  }
152 
153 
154  // ------------------------- private data --------------------------------
155  private:
159  TConstIterator myBegin;
163  TConstIterator myEnd;
164 
165  // ------------------------- iterator services --------------------------------
166  public:
167 
173  return ConstIterator( myBegin );
174  }
175 
180  ConstIterator end() const {
181  return ConstIterator( myEnd );
182  }
183 
189  return ConstReverseIterator(this->end());
190  }
191 
196  ConstReverseIterator rend() const {
197  return ConstReverseIterator(this->begin());
198  }
199 
204  ConstCirculator c() const {
205  return ConstCirculator( this->begin(), this->begin(), this->end() );
206  }
207 
212  ConstReverseCirculator rc() const {
213  return ConstReverseCirculator( this->c() );
214  }
215 
216  }; //end class SimpleConstRange
217 
218 } // namespace DGtal
219 
221 
222 
223 #endif // !defined SimpleConstRange_h
224 
225 #undef SimpleConstRange_RECURSES
226 #endif // else defined(SimpleConstRange_RECURSES)
DGtal::Circulator
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:86
DGtal::SimpleConstRange::c
ConstCirculator c() const
Definition: SimpleConstRange.h:204
DGtal::SimpleConstRange::~SimpleConstRange
~SimpleConstRange()
Definition: SimpleConstRange.h:123
DGtal::SimpleConstRange::ConstReverseIterator
std::reverse_iterator< ConstIterator > ConstReverseIterator
Definition: SimpleConstRange.h:81
DGtal::SimpleConstRange::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((boost::BidirectionalIterator< TConstIterator >))
DGtal::SimpleConstRange::myEnd
TConstIterator myEnd
Definition: SimpleConstRange.h:163
DGtal::SimpleConstRange::end
ConstIterator end() const
Definition: SimpleConstRange.h:180
DGtal::SimpleConstRange::myBegin
TConstIterator myBegin
Definition: SimpleConstRange.h:159
DGtal::SimpleConstRange
Aim: model of CConstRange that adapts any range of elements bounded by two iterators [itb,...
Definition: SimpleConstRange.h:73
DGtal::SimpleConstRange::rc
ConstReverseCirculator rc() const
Definition: SimpleConstRange.h:212
DGtal::SimpleConstRange::rend
ConstReverseIterator rend() const
Definition: SimpleConstRange.h:196
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
boost::BidirectionalIterator
Go to http://www.sgi.com/tech/stl/BidirectionalIterator.html.
Definition: Boost.dox:42
DGtal::SimpleConstRange::ConstIterator
TConstIterator ConstIterator
Definition: SimpleConstRange.h:80
DGtal::SimpleConstRange::operator=
SimpleConstRange & operator=(const SimpleConstRange &other)
Definition: SimpleConstRange.h:110
DGtal::SimpleConstRange::SimpleConstRange
SimpleConstRange(const TConstIterator &itb, const TConstIterator &ite)
Definition: SimpleConstRange.h:95
DGtal::SimpleConstRange::SimpleConstRange
SimpleConstRange(const SimpleConstRange &other)
Definition: SimpleConstRange.h:102
DGtal::SimpleConstRange::ConstCirculator
Circulator< ConstIterator > ConstCirculator
Definition: SimpleConstRange.h:83
DGtal::SimpleConstRange::className
std::string className() const
Definition: SimpleConstRange.h:148
DGtal::SimpleConstRange::begin
ConstIterator begin() const
Definition: SimpleConstRange.h:172
DGtal::IteratorCirculatorTraits::Value
IC::value_type Value
Definition: IteratorCirculatorTraits.h:303
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::SimpleConstRange::selfDisplay
void selfDisplay(std::ostream &out) const
Definition: SimpleConstRange.h:136
DGtal::SimpleConstRange::ConstReverseCirculator
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
Definition: SimpleConstRange.h:84
DGtal::SimpleConstRange::isValid
bool isValid() const
Definition: SimpleConstRange.h:129
DGtal::SimpleConstRange::rbegin
ConstReverseIterator rbegin() const
Definition: SimpleConstRange.h:188