DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
InputIteratorWithRankOnSequence.ih
1 
30 
31 #include <cstdlib>
33 
35 // IMPLEMENTATION of inline methods.
37 
39 // ----------------------- Standard services ------------------------------
40 
41 //-----------------------------------------------------------------------------
42 template <typename TSequence, typename TRank>
43 inline
46 {
47 }
48 //-----------------------------------------------------------------------------
49 template <typename TSequence, typename TRank>
50 inline
53  : mySequence( new Sequence( seq ) ), myIterator( it )
54 {
55 }
56 //-----------------------------------------------------------------------------
57 template <typename TSequence, typename TRank>
58 inline
61  : mySequence( ptrSeq ), myIterator( it )
62 {
63 }
64 //-----------------------------------------------------------------------------
65 template <typename TSequence, typename TRank>
66 inline
69 ( const CountedPtr<Sequence> & ptrSeq, ConstIterator it )
70  : mySequence( ptrSeq ), myIterator( it )
71 {
72 }
73 //-----------------------------------------------------------------------------
74 template <typename TSequence, typename TRank>
75 inline
78  : mySequence( other.mySequence ), myIterator( other.myIterator )
79 {
80 }
81 //-----------------------------------------------------------------------------
82 template <typename TSequence, typename TRank>
83 inline
86 operator= ( const Self & other )
87 {
88  if ( this != &other )
89  {
90  mySequence = other.mySequence;
91  myIterator = other.myIterator;
92  }
93  return *this;
94 }
95 //-----------------------------------------------------------------------------
96 template <typename TSequence, typename TRank>
97 inline
100 operator*() const
101 {
102  return std::make_pair( *myIterator, (Rank) ( myIterator - mySequence->begin() ) );
103 }
104 //-----------------------------------------------------------------------------
105 template <typename TSequence, typename TRank>
106 inline
109 operator->() const
110 {
111  myTmpValue = this->operator*();
112  return &myTmpValue;
113 }
114 //-----------------------------------------------------------------------------
115 template <typename TSequence, typename TRank>
116 inline
120 {
121  ++myIterator;
122  return *this;
123 }
124 //-----------------------------------------------------------------------------
125 template <typename TSequence, typename TRank>
126 inline
130 {
131  Self tmp = *this;
132  ++myIterator;
133  return tmp;
134 }
135 //-----------------------------------------------------------------------------
136 template <typename TSequence, typename TRank>
137 inline
138 bool
140 operator==( const Self & other ) const
141 {
142  if ( mySequence.get() != 0 )
143  {
144  if ( other.mySequence.get() != 0 )
145  return ( myIterator == other.myIterator );
146  else
147  return ( myIterator == mySequence->end() );
148  }
149  else
150  {
151  if ( other.mySequence.get() != 0 )
152  return ( other.myIterator == other.mySequence->end() );
153  else
154  return true;
155  }
156 }
157 //-----------------------------------------------------------------------------
158 template <typename TSequence, typename TRank>
159 inline
160 bool
162 operator!=( const Self & other ) const
163 {
164  return ! this->operator==( other );
165 }
166 
168 // Interface - public :
169 
174 template <typename TSequence, typename TRank>
175 inline
176 void
178 selfDisplay ( std::ostream & out ) const
179 {
180  out << "[InputIteratorWithRankOnSequence]";
181 }
182 
187 template <typename TSequence, typename TRank>
188 inline
189 bool
191 isValid() const
192 {
193  return true;
194 }
195 
196 
197 
199 // Implementation of inline functions //
200 
201 template <typename TSequence, typename TRank>
202 inline
203 std::ostream&
204 DGtal::operator<< ( std::ostream & out,
206 {
207  object.selfDisplay( out );
208  return out;
209 }
210 
211 // //
213 
214