DGtal  0.9.2
InputIteratorWithRankOnSequence.h
1 
17 #pragma once
18 
31 #if defined(InputIteratorWithRankOnSequence_RECURSES)
32 #error Recursive header files inclusion detected in InputIteratorWithRankOnSequence.h
33 #else // defined(InputIteratorWithRankOnSequence_RECURSES)
34 
35 #define InputIteratorWithRankOnSequence_RECURSES
36 
37 #if !defined InputIteratorWithRankOnSequence_h
38 
39 #define InputIteratorWithRankOnSequence_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <iterator>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/CountedPtr.h"
47 #include "DGtal/kernel/CInteger.h"
49 
50 namespace DGtal
51 {
52 
54  // template class InputIteratorWithRankOnSequence
78  template <typename TSequence, typename TRank = typename TSequence::difference_type>
80  {
81  // ----------------------- public types ------------------------------
82  public:
85 
86  typedef TSequence Sequence;
87  typedef TRank Rank;
89  typedef typename Sequence::value_type SequenceValue;
90  typedef std::pair<SequenceValue,Rank> Value;
91  typedef typename Sequence::const_iterator ConstIterator;
92  typedef Value* Pointer;
93 
94  // ----------------------- std types ----------------------------------
95  typedef Value value_type;
96  typedef typename Sequence::size_type size_type;
97  typedef typename Sequence::difference_type difference_type;
98  typedef Pointer pointer;
99  typedef value_type& reference;
100  typedef reference const_reference;
101  typedef std::input_iterator_tag iterator_category;
102 
103  // ----------------------- Standard services ------------------------------
104  public:
105 
110 
116  InputIteratorWithRankOnSequence( const Sequence & seq, ConstIterator it );
117 
123  InputIteratorWithRankOnSequence( Sequence* ptrSeq, ConstIterator it );
124 
130  InputIteratorWithRankOnSequence( const CountedPtr<Sequence> & ptrSeq, ConstIterator it );
131 
136  InputIteratorWithRankOnSequence ( const Self & other );
137 
143  Self & operator= ( const Self & other );
144 
149  Value operator*() const;
150 
155  Pointer operator->() const;
156 
161  Self& operator++();
162 
167  Self operator++( int );
168 
174  bool operator==( const Self & other ) const;
175 
181  bool operator!=( const Self & other ) const;
182 
183  // ----------------------- Interface --------------------------------------
184  public:
185 
190  void selfDisplay ( std::ostream & out ) const;
191 
196  bool isValid() const;
197 
198  // ------------------------- Protected Datas ------------------------------
199  private:
200  // ------------------------- Private Datas --------------------------------
201  private:
202 
206  ConstIterator myIterator;
209  Value myTmpValue;
210 
211  // ------------------------- Hidden services ------------------------------
212  protected:
217 
218  // ------------------------- Internals ------------------------------------
219  private:
220 
221  }; // end of class InputIteratorWithRankOnSequence
222 
223 
230  template <typename TSequence, typename TRank>
231  std::ostream&
232  operator<< ( std::ostream & out, const InputIteratorWithRankOnSequence<TSequence, TRank> & object );
233 
234 } // namespace DGtal
235 
236 
238 // Includes inline functions.
239 #include "DGtal/base/InputIteratorWithRankOnSequence.ih"
240 
241 // //
243 
244 #endif // !defined InputIteratorWithRankOnSequence_h
245 
246 #undef InputIteratorWithRankOnSequence_RECURSES
247 #endif // else defined(InputIteratorWithRankOnSequence_RECURSES)
BOOST_CONCEPT_ASSERT((boost::Sequence< TSequence >))
Go to http://www.sgi.com/tech/stl/Sequence.html.
Definition: Boost.dox:128
ConstIterator myIterator
The current iterator position on the sequence.
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:87
void selfDisplay(std::ostream &out) const
CountedPtr< Sequence > mySequence
A smart pointer to the visited sequence.
bool operator==(const Self &other) const
Aim: Useful to create an iterator that returns a pair (value,rank) when visiting a sequence...
Self & operator=(const Self &other)
DGtal is the top-level namespace which contains all DGtal functions and types.
bool operator!=(const Self &other) const
InputIteratorWithRankOnSequence< Sequence, Rank > Self