DGtal 1.3.0
Loading...
Searching...
No Matches
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)
35#define IntegerSequenceIterator_RECURSES
36
37#if !defined IntegerSequenceIterator_h
39#define IntegerSequenceIterator_h
40
42// Inclusions
43#include <iostream>
44#include <boost/iterator/iterator_facade.hpp>
45#include "DGtal/base/Common.h"
47
48namespace 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
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)
Aim: It is a simple class that mimics a (non mutable) iterator over integers. You can increment it,...
void increment()
Increments the iterator. Required by boost::iterator_facade.
IntegerSequenceIterator(Integer n=Integer(0))
IntegerSequenceIterator & operator=(const IntegerSequenceIterator &other)=default
bool equal(IntegerSequenceIterator const &other) const
Integer myNumber
The current value of the interator.
std::ptrdiff_t distance_to(IntegerSequenceIterator const &other)
IntegerSequenceIterator(const IntegerSequenceIterator &other)=default
void decrement()
Decrements the iterator. Required by boost::iterator_facade.
IntegerSequenceIterator(IntegerSequenceIterator &&other)=default
IntegerSequenceIterator< TInteger > Self
DGtal is the top-level namespace which contains all DGtal functions and types.