mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-31 04:40:32 +05:00
PLA13330( When mesh generation does not success, trace where )
add templates of map iterators
This commit is contained in:
parent
585d062c21
commit
c03258aaf6
@ -32,13 +32,37 @@
|
|||||||
#include "SMDS_Iterator.hxx"
|
#include "SMDS_Iterator.hxx"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
/// specific SMDS_Iterator iterating over abstract set of values like STL containers
|
/// Accessors to value pointed by iterator
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace SMDS {
|
||||||
|
|
||||||
|
template<typename VALUE,typename VALUE_SET_ITERATOR>
|
||||||
|
struct SimpleAccessor {
|
||||||
|
static VALUE value(VALUE_SET_ITERATOR it) { return (VALUE) *it; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename VALUE,typename VALUE_SET_ITERATOR>
|
||||||
|
struct KeyAccessor {
|
||||||
|
static VALUE value(VALUE_SET_ITERATOR it) { return (VALUE) it->first; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename VALUE,typename VALUE_SET_ITERATOR>
|
||||||
|
struct ValueAccessor {
|
||||||
|
static VALUE value(VALUE_SET_ITERATOR it) { return (VALUE) it->second; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// SMDS_Iterator iterating over abstract set of values like STL containers
|
||||||
///
|
///
|
||||||
/// BE CAREFUL: iterator pointed value is static_cast'ed to VALUE
|
/// BE CAREFUL: iterator pointed value is static_cast'ed to VALUE
|
||||||
///
|
///
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename VALUE, typename VALUE_SET_ITERATOR>
|
template<typename VALUE,
|
||||||
|
typename VALUE_SET_ITERATOR,
|
||||||
|
typename ACCESOR=SMDS::SimpleAccessor<VALUE,VALUE_SET_ITERATOR> >
|
||||||
class SMDS_SetIterator : public SMDS_Iterator<VALUE>
|
class SMDS_SetIterator : public SMDS_Iterator<VALUE>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -57,11 +81,67 @@ public:
|
|||||||
virtual bool more() { return _beg != _end; }
|
virtual bool more() { return _beg != _end; }
|
||||||
|
|
||||||
/// Return the current object and step to the next one
|
/// Return the current object and step to the next one
|
||||||
virtual VALUE next() { return static_cast<VALUE>( *_beg++ ); }
|
virtual VALUE next() { return ACCESOR::value( _beg++ ); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// map iterators
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
/*!
|
||||||
|
* \brief iterator on values of a map
|
||||||
|
*/
|
||||||
|
template<typename M>
|
||||||
|
struct SMDS_mapIterator : public SMDS_SetIterator< typename M::mapped_type, typename M::const_iterator,
|
||||||
|
SMDS::ValueAccessor<typename M::mapped_type,
|
||||||
|
typename M::const_iterator> > {
|
||||||
|
typedef SMDS_SetIterator< typename M::mapped_type, typename M::const_iterator,
|
||||||
|
SMDS::ValueAccessor<typename M::mapped_type,
|
||||||
|
typename M::const_iterator> > parent_type;
|
||||||
|
SMDS_mapIterator(const M& m):parent_type(m.begin(),m.end()) {}
|
||||||
|
};
|
||||||
|
/*!
|
||||||
|
* \brief reverse iterator on values of a map
|
||||||
|
*/
|
||||||
|
template<typename M>
|
||||||
|
struct SMDS_mapReverseIterator : public SMDS_SetIterator< typename M::mapped_type,
|
||||||
|
typename M::const_reverse_iterator,
|
||||||
|
SMDS::ValueAccessor<typename M::mapped_type,
|
||||||
|
typename M::const_reverse_iterator> > {
|
||||||
|
typedef SMDS_SetIterator< typename M::mapped_type, typename M::const_reverse_iterator,
|
||||||
|
SMDS::ValueAccessor<typename M::mapped_type,
|
||||||
|
typename M::const_reverse_iterator> > parent_type;
|
||||||
|
SMDS_mapReverseIterator(const M& m):parent_type(m.rbegin(),m.rend()) {}
|
||||||
|
};
|
||||||
|
/*!
|
||||||
|
* \brief iterator on keys of a map
|
||||||
|
*/
|
||||||
|
template<typename M>
|
||||||
|
struct SMDS_mapKeyIterator : public SMDS_SetIterator< typename M::key_type, typename M::const_iterator,
|
||||||
|
SMDS::KeyAccessor<typename M::key_type,
|
||||||
|
typename M::const_iterator> > {
|
||||||
|
typedef SMDS_SetIterator< typename M::key_type, typename M::const_iterator,
|
||||||
|
SMDS::KeyAccessor<typename M::key_type,
|
||||||
|
typename M::const_iterator> > parent_type;
|
||||||
|
SMDS_mapKeyIterator(const M& m):parent_type(m.begin(),m.end()) {}
|
||||||
|
};
|
||||||
|
/*!
|
||||||
|
* \brief reverse iterator on keys of a map
|
||||||
|
*/
|
||||||
|
template<typename M>
|
||||||
|
struct SMDS_mapKeyReverseIterator : public SMDS_SetIterator< typename M::key_type, typename M::const_iterator,
|
||||||
|
SMDS::KeyAccessor<typename M::key_type,
|
||||||
|
typename M::const_iterator> > {
|
||||||
|
typedef SMDS_SetIterator< typename M::key_type, typename M::const_iterator,
|
||||||
|
SMDS::KeyAccessor<typename M::key_type,
|
||||||
|
typename M::const_iterator> > parent_type;
|
||||||
|
SMDS_mapKeyReverseIterator(const M& m):parent_type(m.rbegin(),m.rend()) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// useful specifications
|
// useful specifications
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user