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 namespace Gecode { namespace Iter { namespace Values {
00035
00042 template<class I, bool strict=false>
00043 class Positive {
00044 protected:
00046 I i;
00047 public:
00049
00050
00051 Positive(void);
00053 Positive(I& i);
00055 void init(I& i);
00057
00059
00060
00061 bool operator ()(void) const;
00063 void operator ++(void);
00065
00067
00068
00069 int val(void) const;
00071 };
00072
00073
00074 template<class I, bool strict>
00075 forceinline
00076 Positive<I,strict>::Positive(void) {}
00077
00078 template<class I, bool strict>
00079 forceinline void
00080 Positive<I,strict>::init(I& i0) {
00081 i=i0;
00082 if (strict) {
00083 while (i() && (i.val() <= 0)) ++i;
00084 } else {
00085 while (i() && (i.val() < 0)) ++i;
00086 }
00087 }
00088
00089 template<class I, bool strict>
00090 forceinline
00091 Positive<I,strict>::Positive(I& i0) : i(i0) {
00092 if (strict) {
00093 while (i() && (i.val() <= 0)) ++i;
00094 } else {
00095 while (i() && (i.val() < 0)) ++i;
00096 }
00097 }
00098
00099 template<class I, bool strict>
00100 forceinline void
00101 Positive<I,strict>::operator ++(void) {
00102 ++i;
00103 }
00104 template<class I, bool strict>
00105 forceinline bool
00106 Positive<I,strict>::operator ()(void) const {
00107 return i();
00108 }
00109
00110 template<class I, bool strict>
00111 forceinline int
00112 Positive<I,strict>::val(void) const {
00113 return i.val();
00114 }
00115
00116 }}}
00117
00118
00119