Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
SimpleConstRange.h
1
16
17#pragma once
18
32
33#if defined(SimpleConstRange_RECURSES)
34#error Recursive header files inclusion detected in SimpleConstRange.h
35#else // defined(SimpleConstRange_RECURSES)
37#define SimpleConstRange_RECURSES
38
39#if !defined SimpleConstRange_h
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"
51#include "boost/iterator/reverse_iterator.hpp"
53
54namespace DGtal
55{
56
57
59 // class SimpleConstRange
61
72 template <typename TConstIterator>
74 {
75
77
78 // ------------------------- inner types --------------------------------
79 public:
80
81 typedef TConstIterator ConstIterator;
82 typedef boost::reverse_iterator<ConstIterator> ConstReverseIterator;
83
85 typedef boost::reverse_iterator<ConstCirculator> ConstReverseCirculator;
86
87 // ------------------------- standard services --------------------------------
88
96 SimpleConstRange(const TConstIterator& itb, const TConstIterator& ite)
97 : myBegin(itb), myEnd(ite) {}
98
104 : myBegin(other.myBegin), myEnd(other.myEnd) {}
105
112 {
113 if ( this != &other )
114 {
115 myBegin = other.myBegin;
116 myEnd = other.myEnd;
117 }
118 return *this;
119 }
120
125
130 bool isValid() const { return true; }
131
132 // ------------------------- display --------------------------------
137 void selfDisplay ( std::ostream & out ) const
138 {
140 out << "[SimpleConstRange]" << std::endl;
141 out << "\t";
142 std::copy( myBegin, myEnd, std::ostream_iterator<Value>(out, ", ") );
143 out << std::endl;
144 }
145
149 std::string className() const
150 {
151 return "SimpleConstRange";
152 }
153
154
155 // ------------------------- private data --------------------------------
156 private:
160 TConstIterator myBegin;
164 TConstIterator myEnd;
165
166 // ------------------------- iterator services --------------------------------
167 public:
168
174 return ConstIterator( myBegin );
175 }
176
182 return ConstIterator( myEnd );
183 }
184
190 return ConstReverseIterator(this->end());
191 }
192
197 ConstReverseIterator rend() const {
198 return ConstReverseIterator(this->begin());
199 }
200
205 ConstCirculator c() const {
206 return ConstCirculator( this->begin(), this->begin(), this->end() );
207 }
208
213 ConstReverseCirculator rc() const {
214 return ConstReverseCirculator( this->c() );
215 }
216
217 }; //end class SimpleConstRange
218
219} // namespace DGtal
220
222
223
224#endif // !defined SimpleConstRange_h
225
226#undef SimpleConstRange_RECURSES
227#endif // else defined(SimpleConstRange_RECURSES)
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition Circulator.h:86
BOOST_CONCEPT_ASSERT((boost::BidirectionalIterator< TConstIterator >))
SimpleConstRange(const SimpleConstRange &other)
ConstIterator end() const
boost::reverse_iterator< ConstCirculator > ConstReverseCirculator
std::string className() const
ConstReverseIterator rbegin() const
ConstReverseCirculator rc() const
Circulator< ConstIterator > ConstCirculator
boost::reverse_iterator< ConstIterator > ConstReverseIterator
SimpleConstRange(const TConstIterator &itb, const TConstIterator &ite)
ConstIterator begin() const
ConstReverseIterator rend() const
SimpleConstRange & operator=(const SimpleConstRange &other)
ConstCirculator c() const
void selfDisplay(std::ostream &out) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Go to http://www.sgi.com/tech/stl/BidirectionalIterator.html.
Definition Boost.dox:42