Skip to content

Commit 66dac13

Browse files
author
Christian Schulte
committed
Do not use init
git-svn-id: file:///Users/tack/GecodeGitMigration/gecode-svn-mirror/gecode/trunk@11019 e85b7adc-8362-4630-8c63-7469d557c915
1 parent 6071eea commit 66dac13

File tree

6 files changed

+7
-19
lines changed

6 files changed

+7
-19
lines changed

examples/crossword.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,9 @@ class Crossword : public Script {
115115
fail();
116116
} else {
117117
// Array of all words of length w_l
118-
IntVarArgs words(n);
119-
for (int i=n; i--; ) {
120-
words[i].init(*this,0,n_w-1);
118+
IntVarArgs words(*this,n,0,n_w-1);
119+
for (int i=n; i--; )
121120
allwords[aw_i++]=words[i];
122-
}
123121

124122
// All words of same length must be different
125123
distinct(*this, words, opt.icl());

examples/kakuro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class Kakuro : public Script {
486486
/// Init the variable \a x if necessary
487487
IntVar init(IntVar& x) {
488488
if (x.min() == 0)
489-
x.init(*this,1,9);
489+
x = IntVar(*this,1,9);
490490
return x;
491491
}
492492
/// Post a distinct-linear constraint on variables \a x with sum \a c

examples/pentominoes.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,7 @@ class Pentominoes : public Script {
386386
} else { // opt.propagation() == PROPAGATION_BOOLEAN
387387
int ncolors = ntiles + 2;
388388
// Boolean variables for channeling
389-
BoolVarArgs p(ncolors * board.size());
390-
for (int i=p.size(); i--; )
391-
p[i].init(*this,0,1);
389+
BoolVarArgs p(*this,ncolors * board.size(),0,1);
392390

393391
// Post channel constraints
394392
for (int i=board.size(); i--; ) {

examples/sports-league.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,8 @@ class SportsLeague : public Script {
229229
// Domain for gamenumber of period
230230
for (int w=0; w<weeks(); w++) {
231231
IntArgs rh(periods()), ra(periods()), rg(periods());
232-
IntVarArgs n(periods());
232+
IntVarArgs n(*this,periods(),0,periods()-1);
233233

234-
for (int p=0; p<periods(); p++)
235-
n[p].init(*this,0,periods()-1);
236234
distinct(*this, n, opt.icl());
237235

238236
r.hag(w,rh,ra,rg);

examples/tsp.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,7 @@ class TSP : public MinimizeScript {
254254
rel(*this, succ[i], IRT_NQ, j);
255255

256256
// Cost of each edge
257-
IntVarArgs costs(n);
258-
259-
// Initialize cost variables for edges
260-
for (int i=n; i--; )
261-
costs[i].init(*this, Int::Limits::min, Int::Limits::max);
257+
IntVarArgs costs(*this, n, Int::Limits::min, Int::Limits::max);
262258

263259
// Enforce that the succesors yield a tour with appropriate costs
264260
circuit(*this, c, succ, costs, total, opt.icl());

examples/word-square.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ class WordSquare : public Script {
8686
const int n_w = dict.words(w_l);
8787

8888
// Initialize word array
89-
IntVarArgs words(w_l);
90-
for (int i=0; i<w_l; i++)
91-
words[i].init(*this,0,n_w-1);
89+
IntVarArgs words(*this, w_l, 0, n_w-1);
9290

9391
// All words must be different
9492
distinct(*this, words);

0 commit comments

Comments
 (0)