DGtal  1.1.0
IntegerSequenceIterator.h
1 
17 #pragma once
18 
31 #if defined(IntegerSequenceIterator_RECURSES)
32 #error Recursive header files inclusion detected in IntegerSequenceIterator.h
33 #else // defined(IntegerSequenceIterator_RECURSES)
34 
35 #define IntegerSequenceIterator_RECURSES
36 
37 #if !defined IntegerSequenceIterator_h
38 
39 #define IntegerSequenceIterator_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <boost/iterator/iterator_facade.hpp>
45 #include "DGtal/base/Common.h"
47 
48 namespace DGtal
49 {
50 
52  // template class IntegerSequenceIterator
64  template <typename TInteger>
66  : public boost::iterator_facade< IntegerSequenceIterator< TInteger >,
67  TInteger const,
68  boost::random_access_traversal_tag >
69  {
70  public:
72  typedef TInteger Integer;
73 
74  // ----------------------- Standard services ------------------------------
75  public:
76 
82 
87 
92  IntegerSequenceIterator ( const IntegerSequenceIterator & other ) = default;
93 
99 
106 
113 
114  // ----------------------- Boost facade services --------------------------------------
115  private:
117 
119  void increment() { myNumber++; }
121  void decrement() { myNumber--; }
124  void advance( std::ptrdiff_t n ) { myNumber += n; }
127  std::ptrdiff_t distance_to( IntegerSequenceIterator const& other )
128  { return other.myNumber - myNumber; }
131  bool equal( IntegerSequenceIterator const& other) const
132  { return this->myNumber == other.myNumber; }
135  Integer const& dereference() const { return myNumber; }
136 
137  // ----------------------- Interface --------------------------------------
138  public:
139 
140  // ------------------------- Protected Datas ------------------------------
141  protected:
144 
145  // ------------------------- Private Datas --------------------------------
146  private:
147 
148  // ------------------------- Hidden services ------------------------------
149  protected:
150 
151  // ------------------------- Internals ------------------------------------
152  private:
153 
154  }; // end of class IntegerSequenceIterator
155 
156 } // namespace DGtal
157 
158 
160 // //
162 
163 #endif // !defined IntegerSequenceIterator_h
164 
165 #undef IntegerSequenceIterator_RECURSES
166 #endif // else defined(IntegerSequenceIterator_RECURSES)
DGtal::IntegerSequenceIterator::distance_to
std::ptrdiff_t distance_to(IntegerSequenceIterator const &other)
Definition: IntegerSequenceIterator.h:127
DGtal::IntegerSequenceIterator::Self
IntegerSequenceIterator< TInteger > Self
Definition: IntegerSequenceIterator.h:71
DGtal::IntegerSequenceIterator::myNumber
Integer myNumber
The current value of the interator.
Definition: IntegerSequenceIterator.h:143
DGtal::IntegerSequenceIterator::IntegerSequenceIterator
IntegerSequenceIterator(const IntegerSequenceIterator &other)=default
DGtal::IntegerSequenceIterator::iterator_core_access
friend class boost::iterator_core_access
Definition: IntegerSequenceIterator.h:116
DGtal::IntegerSequenceIterator::advance
void advance(std::ptrdiff_t n)
Definition: IntegerSequenceIterator.h:124
DGtal::IntegerSequenceIterator
Aim: It is a simple class that mimics a (non mutable) iterator over integers. You can increment it,...
Definition: IntegerSequenceIterator.h:69
DGtal::IntegerSequenceIterator::dereference
Integer const & dereference() const
Definition: IntegerSequenceIterator.h:135
DGtal::IntegerSequenceIterator::decrement
void decrement()
Decrements the iterator. Required by boost::iterator_facade.
Definition: IntegerSequenceIterator.h:121
DGtal::IntegerSequenceIterator::Integer
TInteger Integer
Definition: IntegerSequenceIterator.h:72
DGtal::IntegerSequenceIterator::increment
void increment()
Increments the iterator. Required by boost::iterator_facade.
Definition: IntegerSequenceIterator.h:119
DGtal::IntegerSequenceIterator::IntegerSequenceIterator
IntegerSequenceIterator(IntegerSequenceIterator &&other)=default
DGtal::IntegerSequenceIterator::IntegerSequenceIterator
IntegerSequenceIterator(Integer n=Integer(0))
Definition: IntegerSequenceIterator.h:81
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::IntegerSequenceIterator::operator=
IntegerSequenceIterator & operator=(const IntegerSequenceIterator &other)=default
DGtal::IntegerSequenceIterator::~IntegerSequenceIterator
~IntegerSequenceIterator()=default
DGtal::IntegerSequenceIterator::equal
bool equal(IntegerSequenceIterator const &other) const
Definition: IntegerSequenceIterator.h:131