values-positive.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 namespace Gecode { namespace Iter { namespace Values {
00039
00046 template<class I, bool strict=false>
00047 class Positive {
00048 protected:
00050 I i;
00051 public:
00053
00054
00055 Positive(void);
00057 Positive(I& i);
00059 void init(I& i);
00061
00063
00064
00065 bool operator ()(void) const;
00067 void operator ++(void);
00069
00071
00072
00073 int val(void) const;
00075 };
00076
00077
00078 template<class I, bool strict>
00079 forceinline
00080 Positive<I,strict>::Positive(void) {}
00081
00082 template<class I, bool strict>
00083 forceinline void
00084 Positive<I,strict>::init(I& i0) {
00085 i=i0;
00086 if (strict) {
00087 while (i() && (i.val() <= 0)) ++i;
00088 } else {
00089 while (i() && (i.val() < 0)) ++i;
00090 }
00091 }
00092
00093 template<class I, bool strict>
00094 forceinline
00095 Positive<I,strict>::Positive(I& i0) : i(i0) {
00096 if (strict) {
00097 while (i() && (i.val() <= 0)) ++i;
00098 } else {
00099 while (i() && (i.val() < 0)) ++i;
00100 }
00101 }
00102
00103 template<class I, bool strict>
00104 forceinline void
00105 Positive<I,strict>::operator ++(void) {
00106 ++i;
00107 }
00108 template<class I, bool strict>
00109 forceinline bool
00110 Positive<I,strict>::operator ()(void) const {
00111 return i();
00112 }
00113
00114 template<class I, bool strict>
00115 forceinline int
00116 Positive<I,strict>::val(void) const {
00117 return i.val();
00118 }
00119
00120 }}}
00121
00122
00123