Generated on Fri Aug 24 2012 04:52:13 for Gecode by doxygen 1.8.1.2
set-expr.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2010
8  *
9  * Last modified:
10  * $Date: 2011-01-22 02:01:14 +1100 (Sat, 22 Jan 2011) $ by $Author: schulte $
11  * $Revision: 11553 $
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 #ifdef GECODE_HAS_SET_VARS
39 
40 namespace Gecode {
41 
42  /*
43  * Operations for expressions
44  *
45  */
47  SetExpr::Node::Node(void) : use(1) {}
48 
49  forceinline void*
50  SetExpr::Node::operator new(size_t size) {
51  return heap.ralloc(size);
52  }
53  forceinline void
54  SetExpr::Node::operator delete(void* p, size_t) {
55  heap.rfree(p);
56  }
57 
59  SetExpr::SetExpr(void) : n(NULL) {}
60 
62  SetExpr::SetExpr(const SetExpr& e) : n(e.n) {
63  n->use++;
64  }
65 
66  forceinline bool
68  return (t0==t1) || (t1==NT_VAR) || (t1==NT_CONST) || (t1==NT_LEXP);
69  }
70 
71  inline SetVar
72  SetExpr::post(Home home) const {
73  Region r(home);
74  SetVar s(home,IntSet::empty,
76  NNF::nnf(r,n,false)->post(home,SRT_EQ,s);
77  return s;
78  }
79 
80  inline void
81  SetExpr::post(Home home, SetRelType srt, const SetExpr& e) const {
82  Region r(home);
83  return NNF::nnf(r,n,false)->post(home,srt,NNF::nnf(r,e.n,false));
84  }
85  inline void
86  SetExpr::post(Home home, BoolVar b, bool t,
87  SetRelType srt, const SetExpr& e) const {
88  Region r(home);
89  return NNF::nnf(r,n,false)->post(home,b,t,srt,NNF::nnf(r,e.n,false));
90  }
91 
92 }
93 
94 #endif
95 
96 // STATISTICS: minimodel-any