Version: 8.3.0
SMDS_StdIterator.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 // SMESH SMDS : implementaion of Salome mesh data structure
21 // File : SMDS_StdIterator.hxx
22 // Created : Fri Feb 5 11:03:46 2010
23 // Author : Edward AGAPOV (eap)
24 //
25 #ifndef __SMDS_StdIterator_HXX__
26 #define __SMDS_StdIterator_HXX__
27 
28 
30 
34 
35 
36 template<typename VALUE, class PtrSMDSIterator, class EqualVALUE = std::equal_to<VALUE> >
37 class SMDS_StdIterator : public std::iterator< std::input_iterator_tag, VALUE >
38 {
39  VALUE _value;
40  PtrSMDSIterator _piterator;
41  EqualVALUE _EqualVALUE;
42 
43 public:
45 
46  // constructor to use as return from begin()
47  SMDS_StdIterator( PtrSMDSIterator pItr )
48  : _value( pItr->more() ? (VALUE)(pItr->next()) : 0 ), _piterator(pItr)
49  {}
50  // constructor to use as return from end()
52  {}
53 
55  VALUE operator*() const
56  { return _value; }
57 
58  // Step to the next one
59  _Self&
61  { _value = _piterator->more() ? VALUE( _piterator->next()) : 0; return *this; }
62 
63  // Step to the next one
64  _Self
66  { _Self res = *this; _value = _piterator->more() ? VALUE( _piterator->next()) : 0; return res; }
67 
68  // Test of end
69  bool
70  operator!=(const _Self& __x) const
71  { return !_EqualVALUE( _value, __x._value); }
72 
73  // Test of equality
74  bool
75  operator==(const _Self& __x) const
76  { return _EqualVALUE( _value, __x._value); }
77 
78 };
79 
80 #endif