Version: 9.16.0
SMDS_StdIterator.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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 : 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)
24//
25#ifndef __SMDS_StdIterator_HXX__
26#define __SMDS_StdIterator_HXX__
27
28
30
35
36template<typename VALUE, class PtrSMDSIterator, class EqualVALUE = std::equal_to<VALUE> >
37class SMDS_StdIterator : public std::iterator< std::input_iterator_tag, VALUE >
38{
39 VALUE _value;
40 PtrSMDSIterator _piterator;
41 EqualVALUE _EqualVALUE;
42
43public:
45
46 // constructor to use as return from begin()
47 SMDS_StdIterator( PtrSMDSIterator pItr )
48 : _value( pItr->more() ? VALUE(pItr->next()) : VALUE(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()) : VALUE(0); return *this; }
62
63 // Step to the next one
64 _Self
66 { _Self res = *this; _value = _piterator->more() ? VALUE( _piterator->next()) : VALUE(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
Wrapper over pointer to SMDS_Iterator, like SMDS_ElemIteratorPtr, enabling its usage in std-like way:...
Definition: SMDS_StdIterator.hxx:38
bool operator!=(const _Self &__x) const
Definition: SMDS_StdIterator.hxx:70
SMDS_StdIterator()
Definition: SMDS_StdIterator.hxx:51
bool operator==(const _Self &__x) const
Definition: SMDS_StdIterator.hxx:75
SMDS_StdIterator(PtrSMDSIterator pItr)
Definition: SMDS_StdIterator.hxx:47
SMDS_StdIterator< VALUE, PtrSMDSIterator > _Self
Definition: SMDS_StdIterator.hxx:44
_Self & operator++()
Definition: SMDS_StdIterator.hxx:60
VALUE _value
Definition: SMDS_StdIterator.hxx:39
EqualVALUE _EqualVALUE
Definition: SMDS_StdIterator.hxx:41
PtrSMDSIterator _piterator
Definition: SMDS_StdIterator.hxx:40
VALUE operator*() const
Return the current object.
Definition: SMDS_StdIterator.hxx:55
_Self operator++(int)
Definition: SMDS_StdIterator.hxx:65