Skip to content

Commit 7d8fbfd

Browse files
committed
Cleanups
1 parent 37288ae commit 7d8fbfd

File tree

14 files changed

+7366
-7058
lines changed

14 files changed

+7366
-7058
lines changed

Makefile.dep

Lines changed: 7069 additions & 6885 deletions
Large diffs are not rendered by default.

Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,9 @@ MMSRC0 = \
643643
float-expr.cpp float-rel.cpp float-arith.cpp \
644644
reg.cpp optimize.cpp exception.cpp ipl.cpp
645645
MMHDR0 = \
646-
int-rel.hpp float-rel.hpp exception.hpp matrix.hpp \
646+
int-expr.hpp int-rel.hpp float-expr.hpp float-rel.hpp \
647647
bool-expr.hpp set-expr.hpp set-rel.hpp \
648+
exception.hpp matrix.hpp \
648649
optimize.hpp reg.hpp ldsb.hpp channel.hpp aliases.hpp \
649650
ipl.hpp
650651

gecode/minimodel.hh

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,23 @@ namespace Gecode {
224224
virtual void post(Home home, IntRelType irt, int c,
225225
BoolVar b, const IntPropLevels& ipls) const = 0;
226226
/// Destructor
227-
virtual ~NonLinIntExpr(void) {}
228-
/// Return fresh variable if \a x is NULL, \a x otherwise
229-
static IntVar result(Home home, IntVar* x) {
230-
if (x==NULL)
231-
return IntVar(home,Int::Limits::min,Int::Limits::max);
232-
return *x;
233-
}
234-
/// Constrain \a x to be equal to \a y if \a x is not NULL
235-
static IntVar result(Home home, IntVar* x, IntVar y) {
236-
if (x!=NULL)
237-
rel(home,*x,IRT_EQ,y);
238-
return y;
239-
}
227+
virtual ~NonLinIntExpr(void);
228+
/// Return fresh variable if \a x is null, \a x otherwise
229+
static IntVar result(Home home, IntVar* x);
230+
/// Constrain \a x to be equal to \a y if \a x is not null
231+
static IntVar result(Home home, IntVar* x, IntVar y);
240232
/// Memory management
241-
void* operator new(size_t size) { return heap.ralloc(size); }
233+
void* operator new(size_t s);
242234
/// Memory management
243-
void operator delete(void* p, size_t) { heap.rfree(p); }
235+
void operator delete(void* p, size_t s);
244236
};
245237

238+
}
239+
240+
#include <gecode/minimodel/int-expr.hpp>
241+
242+
namespace Gecode {
243+
246244
/// Linear expressions over integer variables
247245
class LinIntExpr {
248246
friend class LinIntRel;
@@ -323,7 +321,7 @@ namespace Gecode {
323321
/// Post propagator and return variable for value
324322
GECODE_MINIMODEL_EXPORT
325323
IntVar post(Home home, const IntPropLevels& ipls) const;
326-
/// Return non-linear expression inside, or NULL if not non-linear
324+
/// Return non-linear expression inside, or null if not non-linear
327325
GECODE_MINIMODEL_EXPORT
328326
NonLinIntExpr* nle(void) const;
329327
/// Destructor
@@ -791,6 +789,7 @@ namespace Gecode {
791789
//@}
792790

793791
#ifdef GECODE_HAS_FLOAT_VARS
792+
794793
/// Base class for non-linear float expressions
795794
class NonLinFloatExpr {
796795
public:
@@ -802,25 +801,23 @@ namespace Gecode {
802801
virtual void post(Home home, FloatRelType frt, FloatVal c,
803802
BoolVar b) const = 0;
804803
/// Destructor
805-
virtual ~NonLinFloatExpr(void) {}
806-
/// Return fresh variable if \a x is NULL, \a x otherwise
807-
static FloatVar result(Home home, FloatVar* x) {
808-
if (x == NULL)
809-
return FloatVar(home,Float::Limits::min,Float::Limits::max);
810-
return *x;
811-
}
812-
/// Constrain \a x to be equal to \a y if \a x is not NULL
813-
static FloatVar result(Home home, FloatVar* x, FloatVar y) {
814-
if (x!=NULL)
815-
rel(home,*x,FRT_EQ,y);
816-
return y;
817-
}
804+
virtual ~NonLinFloatExpr(void);
805+
/// Return fresh variable if \a x is null, \a x otherwise
806+
static FloatVar result(Home home, FloatVar* x);
807+
/// Constrain \a x to be equal to \a y if \a x is not null
808+
static FloatVar result(Home home, FloatVar* x, FloatVar y);
818809
/// Memory management
819-
void* operator new(size_t size) { return heap.ralloc(size); }
810+
void* operator new(size_t s);
820811
/// Memory management
821-
void operator delete(void* p, size_t) { heap.rfree(p); }
812+
void operator delete(void* p, size_t s);
822813
};
823814

815+
}
816+
817+
#include <gecode/minimodel/float-expr.hpp>
818+
819+
namespace Gecode {
820+
824821
/// %Float expressions
825822
class LinFloatExpr {
826823
friend class LinFloatRel;
@@ -885,7 +882,7 @@ namespace Gecode {
885882
/// Post propagator and return variable for value
886883
GECODE_MINIMODEL_EXPORT
887884
FloatVar post(Home home) const;
888-
/// Return non-linear expression inside, or NULL if not non-linear
885+
/// Return non-linear expression inside, or null if not non-linear
889886
GECODE_MINIMODEL_EXPORT
890887
NonLinFloatExpr* nlfe(void) const;
891888
/// Destructor

gecode/minimodel/bool-expr.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace Gecode {
8484
*
8585
*/
8686
BoolExpr::Node::Node(void)
87-
: use(1), l(NULL), r(NULL), m(NULL) {}
87+
: use(1), l(nullptr), r(nullptr), m(nullptr) {}
8888

8989
BoolExpr::Node::~Node(void) {
9090
delete m;
@@ -102,9 +102,9 @@ namespace Gecode {
102102
bool
103103
BoolExpr::Node::decrement(void) {
104104
if (--use == 0) {
105-
if ((l != NULL) && l->decrement())
105+
if ((l != nullptr) && l->decrement())
106106
delete l;
107-
if ((r != NULL) && r->decrement())
107+
if ((r != nullptr) && r->decrement())
108108
delete r;
109109
return true;
110110
}
@@ -120,8 +120,8 @@ namespace Gecode {
120120
BoolExpr::BoolExpr(const BoolVar& x) : n(new Node) {
121121
n->same = 1;
122122
n->t = NT_VAR;
123-
n->l = NULL;
124-
n->r = NULL;
123+
n->l = nullptr;
124+
n->r = nullptr;
125125
n->x = x;
126126
}
127127

@@ -149,16 +149,16 @@ namespace Gecode {
149149
n->t = NT_NOT;
150150
n->l = l.n;
151151
n->l->use++;
152-
n->r = NULL;
152+
n->r = nullptr;
153153
}
154154
}
155155

156156
BoolExpr::BoolExpr(const LinIntRel& rl)
157157
: n(new Node) {
158158
n->same = 1;
159159
n->t = NT_RLIN;
160-
n->l = NULL;
161-
n->r = NULL;
160+
n->l = nullptr;
161+
n->r = nullptr;
162162
n->rl = rl;
163163
}
164164

@@ -167,8 +167,8 @@ namespace Gecode {
167167
: n(new Node) {
168168
n->same = 1;
169169
n->t = NT_RLINFLOAT;
170-
n->l = NULL;
171-
n->r = NULL;
170+
n->l = nullptr;
171+
n->r = nullptr;
172172
n->rfl = rfl;
173173
}
174174
#endif
@@ -178,17 +178,17 @@ namespace Gecode {
178178
: n(new Node) {
179179
n->same = 1;
180180
n->t = NT_RSET;
181-
n->l = NULL;
182-
n->r = NULL;
181+
n->l = nullptr;
182+
n->r = nullptr;
183183
n->rs = rs;
184184
}
185185

186186
BoolExpr::BoolExpr(const SetCmpRel& rs)
187187
: n(new Node) {
188188
n->same = 1;
189189
n->t = NT_RSET;
190-
n->l = NULL;
191-
n->r = NULL;
190+
n->l = nullptr;
191+
n->r = nullptr;
192192
n->rs = rs;
193193
}
194194
#endif
@@ -197,8 +197,8 @@ namespace Gecode {
197197
: n(new Node) {
198198
n->same = 1;
199199
n->t = NT_MISC;
200-
n->l = NULL;
201-
n->r = NULL;
200+
n->l = nullptr;
201+
n->r = nullptr;
202202
n->m = m;
203203
}
204204

@@ -566,7 +566,7 @@ namespace Gecode {
566566
GECODE_NEVER;
567567
}
568568
GECODE_NEVER;
569-
return NULL;
569+
return nullptr;
570570
}
571571
}
572572

gecode/minimodel/float-arith.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,18 @@ namespace Gecode { namespace MiniModel {
304304
x[i] = a[i].post(home);
305305
rel(home, x, frt, c);
306306
} else {
307-
rel(home, post(home,NULL), frt, c);
307+
rel(home, post(home,nullptr), frt, c);
308308
}
309309
}
310310
virtual void post(Home home, FloatRelType frt, FloatVal c,
311311
BoolVar b) const {
312-
rel(home, post(home,NULL), frt, c, b);
312+
rel(home, post(home,nullptr), frt, c, b);
313313
}
314314
};
315315
/// Check if \a e is of type \a t
316316
bool hasType(const LinFloatExpr& e, ArithNonLinFloatExpr::ArithNonLinFloatExprType t) {
317317
return e.nlfe() &&
318-
dynamic_cast<ArithNonLinFloatExpr*>(e.nlfe()) != NULL &&
318+
dynamic_cast<ArithNonLinFloatExpr*>(e.nlfe()) != nullptr &&
319319
dynamic_cast<ArithNonLinFloatExpr*>(e.nlfe())->t == t;
320320
}
321321

0 commit comments

Comments
 (0)