DGtal 1.3.0
Loading...
Searching...
No Matches
IteratorCompletion.h
1
17#pragma once
18
29#if defined(IteratorCompletion_RECURSES)
30#error Recursive header files inclusion detected in IteratorCompletion.h
31#else // defined(IteratorCompletion_RECURSES)
33#define IteratorCompletion_RECURSES
34
35#if !defined IteratorCompletion_h
37#define IteratorCompletion_h
38
40// Inclusions
41#include <boost/iterator/reverse_iterator.hpp>
42#include <DGtal/base/SimpleRandomAccessRangeFromPoint.h>
43#include <DGtal/base/SimpleRandomAccessConstRangeFromPoint.h>
45
46namespace DGtal
47{
48
50
65 template < typename TDerived >
67
113 template <
114 typename TDerived
115 >
117 {
118 public:
119
123
124 typedef boost::reverse_iterator<Iterator> ReverseIterator;
125 typedef boost::reverse_iterator<ConstIterator> ConstReverseIterator;
128 typedef std::ptrdiff_t Difference;
129
135 {
136 return ReverseIterator( static_cast<TDerived*>(this)->end() );
137 }
138
143 inline
145 {
146 return ConstReverseIterator( static_cast<TDerived*>(this)->end() );
147 }
148
153 inline
155 {
156 return ConstReverseIterator( static_cast<TDerived*>(this)->cend() );
157 }
158
163 inline
165 {
166 return ReverseIterator( static_cast<TDerived*>(this)->begin() );
167 }
168
173 inline
175 {
176 return ConstReverseIterator( static_cast<TDerived*>(this)->begin() );
177 }
178
183 inline
185 {
186 return ConstReverseIterator( static_cast<TDerived*>(this)->cbegin() );
187 }
188
194 inline
196 {
197 TDerived* const derived = static_cast<TDerived*>(this);
198 return Range(
199 derived->begin(),
200 derived->end(),
202 );
203 }
204
210 inline
212 {
213 TDerived const* const derived = static_cast<TDerived const*>(this);
214 return ConstRange(
215 derived->begin(),
216 derived->end(),
218 );
219 }
220
221 protected:
222
225 {}
226 };
227
228} // namespace DGtal
229
230// //
232
233#endif // !defined IteratorCompletion_h
234
235#undef IteratorCompletion_RECURSES
236#endif // else defined(IteratorCompletion_RECURSES)
237
Aim: Traits that must be specialized for each IteratorCompletion derived class.
Aim: Class that uses CRTP to add reverse iterators and ranges to a derived class.
IteratorCompletionTraits< TDerived >::ConstIterator ConstIterator
Constant iterator type.
~IteratorCompletion()
Protected destructor to avoid memory leak.
IteratorCompletionTraits< TDerived >::Iterator Iterator
Mutable iterator type.
SimpleRandomAccessRangeFromPoint< ConstIterator, Iterator, DistanceFunctor > Range
Mutable range type.
ConstReverseIterator crend() const
std::ptrdiff_t Difference
Type of the distance between two iterators.
ConstReverseIterator rend() const
IteratorCompletionTraits< TDerived >::DistanceFunctor DistanceFunctor
Type of the functor calculating the distance between iterators.
ConstReverseIterator rbegin() const
boost::reverse_iterator< Iterator > ReverseIterator
Mutable reverse iterator type.
ConstReverseIterator crbegin() const
boost::reverse_iterator< ConstIterator > ConstReverseIterator
Constant reverse iterator type.
SimpleRandomAccessConstRangeFromPoint< ConstIterator, DistanceFunctor > ConstRange
Constant range type.
ConstRange constRange() const
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
DGtal is the top-level namespace which contains all DGtal functions and types.