main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:07 for Gecode by
doxygen
1.8.4
gecode
set
rel-op.cpp
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
* Contributing authors:
7
* Gabor Szokoli <szokoli@gecode.org>
8
*
9
* Copyright:
10
* Guido Tack, 2004, 2005
11
*
12
* Last modified:
13
* $Date: 2010-03-03 17:40:32 +0100 (Wed, 03 Mar 2010) $ by $Author: schulte $
14
* $Revision: 10365 $
15
*
16
* This file is part of Gecode, the generic constraint
17
* development environment:
18
* http://www.gecode.org
19
*
20
* Permission is hereby granted, free of charge, to any person obtaining
21
* a copy of this software and associated documentation files (the
22
* "Software"), to deal in the Software without restriction, including
23
* without limitation the rights to use, copy, modify, merge, publish,
24
* distribute, sublicense, and/or sell copies of the Software, and to
25
* permit persons to whom the Software is furnished to do so, subject to
26
* the following conditions:
27
*
28
* The above copyright notice and this permission notice shall be
29
* included in all copies or substantial portions of the Software.
30
*
31
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
*
39
*/
40
41
#include <
gecode/set/rel-op.hh
>
42
43
namespace
Gecode {
44
using namespace
Gecode::Set;
45
using namespace
Gecode::Set::Rel;
46
using namespace
Gecode::Set::RelOp;
47
48
void
49
rel
(
Home
home,
SetOpType
op,
const
SetVarArgs
&
x
,
SetVar
y) {
50
if
(home.
failed
())
return
;
51
ViewArray<SetView>
xa(home,x);
52
switch
(op) {
53
case
SOT_UNION
:
54
GECODE_ES_FAIL
((
RelOp::UnionN<SetView,SetView>::post
(home, xa, y)));
55
break
;
56
case
SOT_DUNION
:
57
GECODE_ES_FAIL
(
58
(
RelOp::PartitionN<SetView,SetView>::post
(home, xa, y)));
59
break
;
60
case
SOT_INTER
:
61
{
62
GECODE_ES_FAIL
(
63
(
RelOp::IntersectionN<SetView,SetView>
64
::
post
(home, xa, y)));
65
}
66
break
;
67
case
SOT_MINUS
:
68
throw
IllegalOperation
(
"Set::rel"
);
69
break
;
70
default
:
71
throw
UnknownOperation
(
"Set::rel"
);
72
}
73
}
74
75
void
76
rel
(
Home
home,
SetOpType
op,
const
SetVarArgs
&
x
,
const
IntSet
& z,
SetVar
y) {
77
if
(home.
failed
())
return
;
78
Set::Limits::check
(z,
"Set::rel"
);
79
ViewArray<SetView>
xa(home,x);
80
switch
(op) {
81
case
SOT_UNION
:
82
GECODE_ES_FAIL
((
RelOp::UnionN<SetView,SetView>::post
(home, xa, z, y)));
83
break
;
84
case
SOT_DUNION
:
85
GECODE_ES_FAIL
(
86
(
RelOp::PartitionN<SetView,SetView>::post
(home, xa, z, y)));
87
break
;
88
case
SOT_INTER
:
89
{
90
GECODE_ES_FAIL
(
91
(
RelOp::IntersectionN<SetView,SetView>
92
::
post
(home, xa, z, y)));
93
}
94
break
;
95
case
SOT_MINUS
:
96
throw
IllegalOperation
(
"Set::rel"
);
97
break
;
98
default
:
99
throw
UnknownOperation
(
"Set::rel"
);
100
}
101
}
102
103
}
104
105
// STATISTICS: set-post