00001 #ifndef ITER_PAIR_H 00002 #define ITER_PAIR_H 00003 00004 #include <iterator> 00005 00006 template< class Iter > 00007 class IterPair 00008 { 00009 public: 00010 typedef Iter itype; 00011 IterPair( const Iter b, const Iter e ) : m_begin(b), m_end(e) {} 00012 IterPair( const IterPair& x ) 00013 { 00014 *this = x; 00015 } 00016 IterPair& operator=(const IterPair& x) 00017 { 00018 m_begin=x.m_begin; 00019 m_end=x.m_end; 00020 return( *this ); 00021 } 00022 bool operator==(const IterPair& x) const 00023 { 00024 return( m_begin==x.m_begin && m_end==x.m_end ); 00025 } 00026 bool empty() const { return( m_begin==m_end ); } 00027 unsigned length() const { return( std::distance( m_begin, m_end )); } 00028 Iter begin() const { return( m_begin ); } 00029 Iter end() const { return( m_end ); } 00030 protected: 00031 Iter m_begin; 00032 Iter m_end; 00033 }; 00034 00035 template< class Container, class Iter > 00036 IterPair<Iter> MakeIterPair( Container& c ) 00037 { 00038 return( IterPair<Iter>( c.begin(), c.end() )); 00039 } 00040 00041 template< class Pred, class Iter > 00042 class MakeCondIterPair : public IterPair<Iter> 00043 { 00044 typedef IterPair<Iter> _bclass; 00045 public: 00046 MakeCondIterPair( const Iter& b, const Iter& e ) : 00047 _bclass( b, e ) {} 00048 }; 00049 00050 #endif
1.4.4