Generated on Sat Feb 7 2015 02:01:28 for Gecode by doxygen 1.8.9.1
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 12:44:17 +0200 (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  RangeList(void);
65  RangeList(int min, int max, RangeList* n);
67 
69 
70  int min(void) const;
73  int max(void) const;
75  unsigned int width(void) const;
76 
78  RangeList* next(void) const;
80 
82 
83  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 
118 
121  : FreeList(n), _min(min), _max(max) {}
122 
124  RangeList::next() const {
125  return static_cast<RangeList*>(FreeList::next());
126  }
127 
128  forceinline void
130  _min = n;
131  }
132  forceinline void
134  _max = n;
135  }
136  forceinline void
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
180  home.fl_dispose<sizeof(RangeList)>(this,l);
181  }
182 
183 }
184 // STATISTICS: kernel-other
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
FreeList * next(void) const
Return next freelist object.
int min(void) const
Return minimum.
Definition: range-list.hpp:142
Computation spaces.
Definition: core.hpp:1362
int max(void) const
Return maximum.
Definition: range-list.hpp:146
Min _min("Int::Min")
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Max _max("Int::Max")
RangeList * next(void) const
Return next element.
Definition: range-list.hpp:124
int _max
Maximum of range.
Definition: range-list.hpp:58
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
#define forceinline
Definition: config.hpp:132
Base-class for freelist-managed objects.
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Definition: core.hpp:2387
void dispose(Space &home, RangeList *l)
Free memory for all elements between this and l (inclusive)
Definition: range-list.hpp:179
Lists of ranges (intervals)
Definition: range-list.hpp:53
Gecode toplevel namespace
int _min
Minimum of range.
Definition: range-list.hpp:56
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
unsigned int width(void) const
Return width (distance between maximum and minimum)
Definition: range-list.hpp:150
RangeList(void)
Default constructor (noop)
Definition: range-list.hpp:117