main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Aug 25 2012 03:32:47 for Gecode by
doxygen
1.8.1.2
gecode
int
var
int.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Copyright:
7
* Christian Schulte, 2002
8
*
9
* Last modified:
10
* $Date: 2010-09-01 00:19:34 +1000 (Wed, 01 Sep 2010) $ by $Author: schulte $
11
* $Revision: 11366 $
12
*
13
* This file is part of Gecode, the generic constraint
14
* development environment:
15
* http://www.gecode.org
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining
18
* a copy of this software and associated documentation files (the
19
* "Software"), to deal in the Software without restriction, including
20
* without limitation the rights to use, copy, modify, merge, publish,
21
* distribute, sublicense, and/or sell copies of the Software, and to
22
* permit persons to whom the Software is furnished to do so, subject to
23
* the following conditions:
24
*
25
* The above copyright notice and this permission notice shall be
26
* included in all copies or substantial portions of the Software.
27
*
28
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
*
36
*/
37
38
namespace
Gecode {
39
40
forceinline
void
41
IntVar::_init(Space& home,
int
min
,
int
max
) {
42
x
=
new
(home) Int::IntVarImp(home,min,max);
43
}
44
45
forceinline
void
46
IntVar::_init(Space& home,
const
IntSet& ds) {
47
x
=
new
(home) Int::IntVarImp(home,ds);
48
}
49
50
forceinline
51
IntVar::IntVar
(
void
) {}
52
forceinline
53
IntVar::IntVar
(
const
IntVar
& y)
54
:
VarImpVar
<Int::
IntVarImp
>(y.varimp()) {}
55
forceinline
56
IntVar::IntVar
(
const
Int::IntView
& y)
57
:
VarImpVar
<Int::
IntVarImp
>(y.varimp()) {}
58
59
forceinline
int
60
IntVar::val
(
void
)
const
{
61
if
(!
x
->
assigned
())
62
throw
Int::ValOfUnassignedVar
(
"IntVar::val"
);
63
return
x
->
val
();
64
}
65
forceinline
int
66
IntVar::min
(
void
)
const
{
67
return
x
->
min
();
68
}
69
forceinline
int
70
IntVar::med
(
void
)
const
{
71
return
x
->
med
();
72
}
73
forceinline
int
74
IntVar::max
(
void
)
const
{
75
return
x
->
max
();
76
}
77
78
79
forceinline
unsigned
int
80
IntVar::width
(
void
)
const
{
81
return
x
->
width
();
82
}
83
forceinline
unsigned
int
84
IntVar::size
(
void
)
const
{
85
return
x
->
size
();
86
}
87
forceinline
unsigned
int
88
IntVar::regret_min
(
void
)
const
{
89
return
x
->
regret_min
();
90
}
91
forceinline
unsigned
int
92
IntVar::regret_max
(
void
)
const
{
93
return
x
->
regret_max
();
94
}
95
96
forceinline
bool
97
IntVar::range
(
void
)
const
{
98
return
x
->
range
();
99
}
100
forceinline
bool
101
IntVar::in
(
int
n)
const
{
102
return
x
->
in
(n);
103
}
104
105
/*
106
* Range iterator
107
*
108
*/
109
forceinline
110
IntVarRanges::IntVarRanges
(
void
) {}
111
112
forceinline
113
IntVarRanges::IntVarRanges
(
const
IntVar
& x)
114
: Int::
IntVarImpFwd
(x.varimp()) {}
115
116
forceinline
void
117
IntVarRanges::init
(
const
IntVar
& x) {
118
Int::IntVarImpFwd::init
(x.
varimp
());
119
}
120
121
122
/*
123
* Value iterator
124
*
125
*/
126
127
forceinline
128
IntVarValues::IntVarValues
(
void
) {}
129
130
forceinline
131
IntVarValues::IntVarValues
(
const
IntVar
& x) {
132
IntVarRanges
r
(x);
133
Iter::Ranges::ToValues<IntVarRanges>::init
(r);
134
}
135
136
forceinline
void
137
IntVarValues::init
(
const
IntVar
& x) {
138
IntVarRanges
r
(x);
139
Iter::Ranges::ToValues<IntVarRanges>::init
(r);
140
}
141
142
}
143
144
// STATISTICS: int-var
145