values-negative.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 Negative {
00048 protected:
00050 I i;
00051 public:
00053
00054
00055 Negative(void);
00057 Negative(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 Negative<I,strict>::Negative(void) {}
00081
00082 template<class I, bool strict>
00083 forceinline void
00084 Negative<I,strict>::init(I& i0) {
00085 i=i0;
00086 }
00087
00088 template<class I, bool strict>
00089 forceinline
00090 Negative<I,strict>::Negative(I& i0) : i(i0) {}
00091
00092 template<class I, bool strict>
00093 forceinline void
00094 Negative<I,strict>::operator ++(void) {
00095 ++i;
00096 }
00097 template<class I, bool strict>
00098 forceinline bool
00099 Negative<I,strict>::operator ()(void) const {
00100 if (strict) {
00101 return i() && (i.val() < 0);
00102 } else {
00103 return i() && (i.val() <= 0);
00104 }
00105 }
00106
00107 template<class I, bool strict>
00108 forceinline int
00109 Negative<I,strict>::val(void) const {
00110 return i.val();
00111 }
00112
00113 }}}
00114
00115
00116