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