1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SMESH SMDS : implementation of Salome mesh data structure
21 // File : SMDS_StdIterator.hxx
22 // Created : Fri Feb 5 11:03:46 2010
23 // Author : Edward AGAPOV (eap)
25 #ifndef __SMDS_StdIterator_HXX__
26 #define __SMDS_StdIterator_HXX__
29 ///////////////////////////////////////////////////////////////////////////////
31 * \brief Wrapper over pointer to SMDS_Iterator, like SMDS_ElemIteratorPtr, enabling
32 * its usage in std-like way: provide operators ++, *, etc.
34 ///////////////////////////////////////////////////////////////////////////////
36 template<typename VALUE, class PtrSMDSIterator, class EqualVALUE = std::equal_to<VALUE> >
37 class SMDS_StdIterator : public std::iterator< std::input_iterator_tag, VALUE >
40 PtrSMDSIterator _piterator;
41 EqualVALUE _EqualVALUE;
44 typedef SMDS_StdIterator<VALUE, PtrSMDSIterator> _Self;
46 // constructor to use as return from begin()
47 SMDS_StdIterator( PtrSMDSIterator pItr )
48 : _value( pItr->more() ? VALUE(pItr->next()) : VALUE(0) ), _piterator(pItr)
50 // constructor to use as return from end()
51 SMDS_StdIterator(): _value( 0 )
54 /// Return the current object
55 VALUE operator*() const
58 // Step to the next one
61 { _value = _piterator->more() ? VALUE( _piterator->next()) : VALUE(0); return *this; }
63 // Step to the next one
66 { _Self res = *this; _value = _piterator->more() ? VALUE( _piterator->next()) : VALUE(0); return res; }
70 operator!=(const _Self& __x) const
71 { return !_EqualVALUE( _value, __x._value); }
75 operator==(const _Self& __x) const
76 { return _EqualVALUE( _value, __x._value); }