set-expr.icc
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
00039
00040
00041
00042 namespace Gecode {
00043
00044
00045
00046
00047
00048
00049 forceinline
00050 SetExprCode::Stream::Stream(void) : n(0) {}
00051
00052 forceinline void
00053 SetExprCode::Stream::add(int i) {
00054 is[n++] = i;
00055 }
00056
00057 forceinline int
00058 SetExprCode::Stream::size(void) const {
00059 return n;
00060 }
00061
00062 forceinline int
00063 SetExprCode::Stream::operator[](int i) const {
00064 return is[i];
00065 }
00066
00067
00068
00069 forceinline
00070 SetExprCode::SetExprCode(void) {}
00071
00072 forceinline
00073 SetExprCode::SetExprCode(const SetExprCode::Stream& s)
00074 : c(s.size()) {
00075 for (int i=s.size(); i--; )
00076 c[i]=s[i];
00077 }
00078
00079 forceinline
00080 SetExprCode::SetExprCode(const SetExprCode& sc) : c(sc.c) {}
00081
00082 forceinline void
00083 SetExprCode::update(Space* home, bool share, SetExprCode& sc) {
00084 c.update(home, share, sc.c);
00085 }
00086
00087 forceinline int
00088 SetExprCode::size(void) const { return c.size(); }
00089
00090 forceinline int
00091 SetExprCode::operator[](int i) const { return c[i]; }
00092
00093
00094
00095
00096
00097
00098
00099 forceinline
00100 SetExpr::SetExpr(void) : ax(NULL), sign(1) {}
00101
00102 }
00103
00104 inline Gecode::SetExpr
00105 operator-(const Gecode::SetExpr& s) { return Gecode::SetExpr(s, -1); }
00106
00107 inline Gecode::SetExpr
00108 operator||(const Gecode::SetExpr& s, const Gecode::SetExpr& t) {
00109 return Gecode::SetExpr(s, 1, Gecode::SetExpr::REL_UNION, t, 1);
00110 }
00111
00112 inline Gecode::SetExpr
00113 operator&&(const Gecode::SetExpr& s, const Gecode::SetExpr& t) {
00114 return Gecode::SetExpr(s, 1, Gecode::SetExpr::REL_INTER, t, 1);
00115 }
00116
00117 inline Gecode::SetExpr
00118 operator-(const Gecode::SetExpr& s, const Gecode::SetExpr& t) {
00119 return Gecode::SetExpr(s, 1, Gecode::SetExpr::REL_INTER, t, -1);
00120 }
00121
00122 namespace Gecode {
00123
00127 class SetExprRanges {
00128 private:
00130 class Iter;
00132 Iter *i;
00133 const SetExprRanges& operator=(const SetExprRanges&);
00134 public:
00136
00137
00138 SetExprRanges(const SetExprRanges&);
00143 SetExprRanges(const ViewArray<Set::SetView>& x, SetExpr& s,
00144 bool monotone);
00149 SetExprRanges(const ViewArray<Set::SetView>& x,
00150 const SetExprCode& s,
00151 bool monotone);
00153 ~SetExprRanges(void);
00155
00157
00158
00159 bool operator()(void);
00161 void operator++(void);
00163
00165
00166
00167 int min(void) const;
00169 int max(void) const;
00171 unsigned int width(void) const;
00173 };
00174
00179 class SetExprRanges::Iter {
00180 public:
00182 Gecode::Iter::Ranges::Virt::Iterator* i;
00184 int num;
00185
00187 Iter(Gecode::Iter::Ranges::Virt::Iterator*);
00189 ~Iter(void);
00191 void increment(void);
00193 bool decrement(void);
00194 };
00195
00196 forceinline
00197 SetExprRanges::Iter::Iter(Gecode::Iter::Ranges::Virt::Iterator* i0)
00198 : i(i0), num(1) {}
00199
00200 forceinline
00201 SetExprRanges::Iter::~Iter(void) { delete i; }
00202
00203 forceinline void
00204 SetExprRanges::Iter::increment(void) { ++num; }
00205
00206 forceinline bool
00207 SetExprRanges::Iter::decrement(void) { return --num==0; }
00208
00209 forceinline
00210 SetExprRanges::SetExprRanges(const SetExprRanges& s) : i(s.i) {
00211 i->increment();
00212 }
00213
00214 forceinline
00215 SetExprRanges::~SetExprRanges(void) {
00216 if (i->decrement())
00217 delete i;
00218 }
00219
00220 forceinline bool
00221 SetExprRanges::operator()(void) { return (*(i->i))(); }
00222
00223 forceinline void
00224 SetExprRanges::operator++(void) { ++(*(i->i)); }
00225
00226 forceinline int
00227 SetExprRanges::min(void) const { return i->i->min(); }
00228
00229 forceinline int
00230 SetExprRanges::max(void) const { return i->i->max(); }
00231
00232 forceinline unsigned int
00233 SetExprRanges::width(void) const { return i->i->width(); }
00234
00235 }
00236
00237