PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00033 //***************************************************************************** 00034 00035 00036 // include basic definitions 00037 #include "pbori_defs.h" 00038 #include "pbori_func.h" 00039 00040 #include "BoolePolynomial.h" 00041 #include "CDelayedTermIter.h" 00042 00043 #include <algorithm> 00044 00045 #ifndef CRestrictedIter_h_ 00046 #define CRestrictedIter_h_ 00047 00048 BEGIN_NAMESPACE_PBORI 00049 00050 00051 template <class Iterator, 00052 class RestrictOp = 00053 default_binder2nd< std::less<typename Iterator::value_type> >, 00054 class IsValidTest = constant_binder2nd< std::not_equal_to<Iterator>, 00055 default_value<Iterator> > > 00056 class CRestrictedIter: 00057 public Iterator { 00058 public: 00059 00060 typedef Iterator base; 00061 typedef IsValidTest is_valid_type; 00062 typedef RestrictOp restrictop_type; 00063 typedef CRestrictedIter<base, restrictop_type, is_valid_type> self; 00064 typedef typename base::value_type value_type; 00065 00066 CRestrictedIter(const base& src, 00067 const restrictop_type& in_range = restrictop_type(), 00068 const is_valid_type& is_valid = is_valid_type() ): 00069 base(src), m_in_range(in_range), m_is_valid(is_valid) { 00070 goToValid(); 00071 } 00072 00073 00074 self& operator++() { 00075 base::operator++(); 00076 goToValid(); 00077 return *this; 00078 } 00079 self operator++(int) { 00080 self result(*this); 00081 self::operator++(); 00082 return result; 00083 } 00084 00085 void goToValid() { 00086 00087 while( isValid() && !inRange() ) { 00088 base::operator++(); 00089 } 00090 } 00091 00092 bool isValid() const { 00093 return m_is_valid(*this); 00094 } 00095 00096 bool inRange() const { 00097 return m_in_range(base::operator*()); 00098 } 00099 00100 private: 00101 restrictop_type m_in_range; 00102 is_valid_type m_is_valid; 00103 }; 00104 00105 00106 00107 END_NAMESPACE_PBORI 00108 00109 #endif