main page
modules
namespaces
classes
files
Gecode home
Generated on Sat May 25 2013 18:00:38 for Gecode by
doxygen
1.8.3.1
gecode
int
ldsb
sym-obj.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christopher Mears <chris.mears@monash.edu>
5
*
6
* Copyright:
7
* Christopher Mears, 2012
8
*
9
* Last modified:
10
* $Date: 2013-03-07 17:39:13 +0100 (Thu, 07 Mar 2013) $ by $Author: schulte $
11
* $Revision: 13458 $
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
#include <
gecode/int/ldsb.hh
>
39
40
namespace
Gecode {
41
SymmetryHandle::SymmetryHandle
(
void
)
42
: ref(NULL) {}
43
SymmetryHandle::SymmetryHandle
(
Int::LDSB::SymmetryObject
* o)
44
: ref(o) {}
45
SymmetryHandle::SymmetryHandle
(
const
SymmetryHandle
& h)
46
: ref(h.ref) {
47
if
(
ref
!= NULL)
48
increment
();
49
}
50
const
SymmetryHandle
&
51
SymmetryHandle::operator=
(
const
SymmetryHandle
& h) {
52
if
(h.
ref
==
ref
)
53
return
*
this
;
54
if
(
ref
!= NULL)
55
decrement
();
56
ref
= h.
ref
;
57
if
(
ref
!= NULL)
58
increment
();
59
return
*
this
;
60
}
61
SymmetryHandle::~SymmetryHandle
(
void
) {
62
if
(
ref
!= NULL)
63
decrement
();
64
}
65
void
66
SymmetryHandle::increment
(
void
) {
67
(
ref
->
nrefs
)++;
68
}
69
void
70
SymmetryHandle::decrement
(
void
) {
71
(
ref
->
nrefs
)--;
72
if
(
ref
->
nrefs
== 0)
73
delete
ref
;
74
ref
= NULL;
75
}
76
}
77
78
namespace
Gecode {
namespace
Int {
namespace
LDSB {
79
80
SymmetryObject::SymmetryObject
(
void
)
81
: nrefs(1) {}
82
SymmetryObject::~SymmetryObject
(
void
) {}
83
84
VariableSymmetryObject::VariableSymmetryObject
(
ArgArray<VarImpBase*>
vars) {
85
nxs
= vars.
size
();
86
xs
=
new
VarImpBase
*[
nxs
];
87
for
(
int
i
= 0 ;
i
<
nxs
;
i
++)
88
xs
[
i
] = vars[
i
];
89
}
90
VariableSymmetryObject::~VariableSymmetryObject
(
void
) {
91
delete
[]
xs
;
92
}
93
94
ValueSymmetryObject::ValueSymmetryObject
(
IntSet
vs)
95
:
values
(vs) {}
96
97
VariableSequenceSymmetryObject::
98
VariableSequenceSymmetryObject
(
ArgArray<VarImpBase*>
x
,
int
ss)
99
: seq_size(ss) {
100
nxs
= x.
size
();
101
xs
=
new
VarImpBase
*[
nxs
];
102
for
(
int
i
= 0 ;
i
<
nxs
;
i
++)
103
xs
[
i
] = x[
i
];
104
}
105
VariableSequenceSymmetryObject::~VariableSequenceSymmetryObject
(
void
) {
106
delete
[]
xs
;
107
}
108
109
ValueSequenceSymmetryObject::ValueSequenceSymmetryObject
(
IntArgs
vs,
int
ss)
110
:
values
(vs), seq_size(ss) {}
111
112
}}}
113
114
// STATISTICS: int-branch