main page
modules
namespaces
classes
files
Gecode home
Generated on Thu Mar 13 2014 04:39:34 for Gecode by
doxygen
1.8.1.2
gecode
kernel
range-list.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
* Contributing authors:
7
* Guido Tack <tack@gecode.org>
8
*
9
* Copyright:
10
* Christian Schulte, 2004
11
* Guido Tack, 2004
12
*
13
* Last modified:
14
* $Date: 2011-05-11 20:44:17 +1000 (Wed, 11 May 2011) $ by $Author: tack $
15
* $Revision: 12001 $
16
*
17
* This file is part of Gecode, the generic constraint
18
* development environment:
19
* http://www.gecode.org
20
*
21
* Permission is hereby granted, free of charge, to any person obtaining
22
* a copy of this software and associated documentation files (the
23
* "Software"), to deal in the Software without restriction, including
24
* without limitation the rights to use, copy, modify, merge, publish,
25
* distribute, sublicense, and/or sell copies of the Software, and to
26
* permit persons to whom the Software is furnished to do so, subject to
27
* the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be
30
* included in all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
*
40
*/
41
42
namespace
Gecode {
43
53
class
RangeList
:
public
FreeList
{
54
protected
:
56
int
_min
;
58
int
_max
;
59
public
:
61
62
63
RangeList
(
void
);
65
RangeList
(
int
min
,
int
max
,
RangeList
* n);
67
69
70
71
int
min
(
void
)
const
;
73
int
max
(
void
)
const
;
75
unsigned
int
width
(
void
)
const
;
76
78
RangeList
*
next
(
void
)
const
;
80
82
83
84
void
min
(
int
n);
86
void
max
(
int
n);
88
void
next
(
RangeList
* n);
90
92
93
96
void
dispose
(
Space
& home,
RangeList
* l);
97
99
static
void
*
operator
new
(
size_t
s,
Space
& home);
101
static
void
*
operator
new
(
size_t
s,
void
* p);
103
static
void
operator
delete
(
void
*);
105
static
void
operator
delete
(
void
*,
Space
& home);
107
static
void
operator
delete
(
void
*,
void
*);
109
};
110
111
/*
112
* Range lists
113
*
114
*/
115
116
forceinline
117
RangeList::RangeList
(
void
) {}
118
119
forceinline
120
RangeList::RangeList
(
int
min
,
int
max
,
RangeList
* n)
121
:
FreeList
(n),
_min
(min),
_max
(max) {}
122
123
forceinline
RangeList
*
124
RangeList::next
()
const
{
125
return
static_cast<
RangeList
*
>
(
FreeList::next
());
126
}
127
128
forceinline
void
129
RangeList::min
(
int
n) {
130
_min
= n;
131
}
132
forceinline
void
133
RangeList::max
(
int
n) {
134
_max
= n;
135
}
136
forceinline
void
137
RangeList::next
(
RangeList
* n) {
138
FreeList::next
(n);
139
}
140
141
forceinline
int
142
RangeList::min
(
void
)
const
{
143
return
_min
;
144
}
145
forceinline
int
146
RangeList::max
(
void
)
const
{
147
return
_max
;
148
}
149
forceinline
unsigned
int
150
RangeList::width
(
void
)
const
{
151
return
static_cast<
unsigned
int
>
(
_max
-
_min
+ 1);
152
}
153
154
155
forceinline
void
156
RangeList::operator
delete
(
void
*) {}
157
158
forceinline
void
159
RangeList::operator
delete
(
void
*,
Space
&) {
160
GECODE_NEVER
;
161
}
162
163
forceinline
void
164
RangeList::operator
delete
(
void
*,
void
*) {
165
GECODE_NEVER
;
166
}
167
168
forceinline
void
*
169
RangeList::operator
new
(size_t,
Space
& home) {
170
return
home.fl_alloc<
sizeof
(
RangeList
)>();
171
}
172
173
forceinline
void
*
174
RangeList::operator
new
(size_t,
void
* p) {
175
return
p;
176
}
177
178
forceinline
void
179
RangeList::dispose
(
Space
& home,
RangeList
* l) {
180
home.
fl_dispose
<
sizeof
(
RangeList
)>(
this
,l);
181
}
182
183
}
184
// STATISTICS: kernel-other