2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @file InputIteratorWithRankOnSequence.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
24 * Implementation of inline methods defined in InputIteratorWithRankOnSequence.h
26 * This file is part of the DGtal library.
30//////////////////////////////////////////////////////////////////////////////
32//////////////////////////////////////////////////////////////////////////////
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
41//-----------------------------------------------------------------------------
42template <typename TSequence, typename TRank>
44DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
45~InputIteratorWithRankOnSequence()
48//-----------------------------------------------------------------------------
49template <typename TSequence, typename TRank>
51DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
52InputIteratorWithRankOnSequence( const Sequence & seq, ConstIterator it )
53 : mySequence( new Sequence( seq ) ), myIterator( it )
56//-----------------------------------------------------------------------------
57template <typename TSequence, typename TRank>
59DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
60InputIteratorWithRankOnSequence( Sequence* ptrSeq, ConstIterator it )
61 : mySequence( ptrSeq ), myIterator( it )
64//-----------------------------------------------------------------------------
65template <typename TSequence, typename TRank>
67DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
68InputIteratorWithRankOnSequence
69( const CountedPtr<Sequence> & ptrSeq, ConstIterator it )
70 : mySequence( ptrSeq ), myIterator( it )
73//-----------------------------------------------------------------------------
74template <typename TSequence, typename TRank>
76DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
77InputIteratorWithRankOnSequence( const Self & other )
78 : mySequence( other.mySequence ), myIterator( other.myIterator )
81//-----------------------------------------------------------------------------
82template <typename TSequence, typename TRank>
84typename DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::Self &
85DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
86operator= ( const Self & other )
90 mySequence = other.mySequence;
91 myIterator = other.myIterator;
95//-----------------------------------------------------------------------------
96template <typename TSequence, typename TRank>
98typename DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::Value
99DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
102 return std::make_pair( *myIterator, (Rank) ( myIterator - mySequence->begin() ) );
104//-----------------------------------------------------------------------------
105template <typename TSequence, typename TRank>
107typename DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::Pointer
108DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
111 myTmpValue = this->operator*();
114//-----------------------------------------------------------------------------
115template <typename TSequence, typename TRank>
117typename DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::Self &
118DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
124//-----------------------------------------------------------------------------
125template <typename TSequence, typename TRank>
127typename DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::Self
128DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
135//-----------------------------------------------------------------------------
136template <typename TSequence, typename TRank>
139DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
140operator==( const Self & other ) const
142 if ( mySequence.get() != 0 )
144 if ( other.mySequence.get() != 0 )
145 return ( myIterator == other.myIterator );
147 return ( myIterator == mySequence->end() );
151 if ( other.mySequence.get() != 0 )
152 return ( other.myIterator == other.mySequence->end() );
157//-----------------------------------------------------------------------------
158template <typename TSequence, typename TRank>
161DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
162operator!=( const Self & other ) const
164 return ! this->operator==( other );
167///////////////////////////////////////////////////////////////////////////////
168// Interface - public :
171 * Writes/Displays the object on an output stream.
172 * @param out the output stream where the object is written.
174template <typename TSequence, typename TRank>
177DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
178selfDisplay ( std::ostream & out ) const
180 out << "[InputIteratorWithRankOnSequence]";
184 * Checks the validity/consistency of the object.
185 * @return 'true' if the object is valid, 'false' otherwise.
187template <typename TSequence, typename TRank>
190DGtal::InputIteratorWithRankOnSequence<TSequence,TRank>::
198///////////////////////////////////////////////////////////////////////////////
199// Implementation of inline functions //
201template <typename TSequence, typename TRank>
204DGtal::operator<< ( std::ostream & out,
205 const InputIteratorWithRankOnSequence<TSequence,TRank> & object )
207 object.selfDisplay( out );
212///////////////////////////////////////////////////////////////////////////////