sym-obj.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christopher Mears <chris.mears@monash.edu>
*
* Copyright:
* Christopher Mears, 2012
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <gecode/int/ldsb.hh>
namespace Gecode {
SymmetryHandle::SymmetryHandle(void)
: ref(NULL) {}
SymmetryHandle::SymmetryHandle(Int::LDSB::SymmetryObject* o)
: ref(o) {}
SymmetryHandle::SymmetryHandle(const SymmetryHandle& h)
: ref(h.ref) {
if (ref != NULL)
increment();
}
const SymmetryHandle&
SymmetryHandle::operator=(const SymmetryHandle& h) {
if (h.ref == ref)
return *this;
if (ref != NULL)
decrement();
ref = h.ref;
if (ref != NULL)
increment();
return *this;
}
SymmetryHandle::~SymmetryHandle(void) {
if (ref != NULL)
decrement();
}
void
SymmetryHandle::increment(void) {
(ref->nrefs)++;
}
void
SymmetryHandle::decrement(void) {
(ref->nrefs)--;
if (ref->nrefs == 0)
delete ref;
ref = NULL;
}
}
namespace Gecode { namespace Int { namespace LDSB {
SymmetryObject::SymmetryObject(void)
: nrefs(1) {}
SymmetryObject::~SymmetryObject(void) {}
VariableSymmetryObject::VariableSymmetryObject(ArgArray<VarImpBase*> vars) {
nxs = vars.size();
xs = new VarImpBase*[nxs];
for (int i = 0 ; i < nxs ; i++)
xs[i] = vars[i];
}
VariableSymmetryObject::~VariableSymmetryObject(void) {
delete [] xs;
}
ValueSymmetryObject::ValueSymmetryObject(IntSet vs)
: values(vs) {}
VariableSequenceSymmetryObject::
VariableSequenceSymmetryObject(ArgArray<VarImpBase*> x, int ss)
: seq_size(ss) {
nxs = x.size();
xs = new VarImpBase*[nxs];
for (int i = 0 ; i < nxs ; i++)
xs[i] = x[i];
}
VariableSequenceSymmetryObject::~VariableSequenceSymmetryObject(void) {
delete [] xs;
}
ValueSequenceSymmetryObject::ValueSequenceSymmetryObject(IntArgs vs, int ss)
: values(vs), seq_size(ss) {}
}}}
// STATISTICS: int-branch
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1607
Gecode::ArgArray
Argument array for non-primitive types.
Definition array.hpp:691
Gecode::IntArgs
Passing integer arguments.
Definition int.hh:628
Gecode::IntSet
Integer sets.
Definition int.hh:174
Gecode::Int::LDSB::SymmetryObject
Implementation of a symmetry at the modelling level.
Definition ldsb.hh:106
Gecode::Int::LDSB::SymmetryObject::nrefs
int nrefs
Number of references that point to this symmetry object.
Definition ldsb.hh:109
Gecode::Int::LDSB::SymmetryObject::SymmetryObject
SymmetryObject(void)
Default constructor.
Definition sym-obj.cpp:76
Gecode::Int::LDSB::SymmetryObject::~SymmetryObject
virtual ~SymmetryObject(void)
Destructor.
Definition sym-obj.cpp:78
Gecode::Int::LDSB::ValueSequenceSymmetryObject::values
IntArgs values
Array of values in symmetry.
Definition ldsb.hh:153
Gecode::Int::LDSB::ValueSequenceSymmetryObject::seq_size
int seq_size
Size of each sequence in symmetry.
Definition ldsb.hh:155
Gecode::Int::LDSB::ValueSequenceSymmetryObject::ValueSequenceSymmetryObject
ValueSequenceSymmetryObject(IntArgs vs, int ss)
Constructor for creation.
Definition sym-obj.cpp:105
Gecode::Int::LDSB::ValueSymmetryObject::values
IntSet values
Set of symmetric values.
Definition ldsb.hh:131
Gecode::Int::LDSB::ValueSymmetryObject::ValueSymmetryObject
ValueSymmetryObject(IntSet vs)
Constructor for creation.
Definition sym-obj.cpp:90
Gecode::Int::LDSB::VariableSequenceSymmetryObject::seq_size
int seq_size
Size of each sequence in symmetry.
Definition ldsb.hh:143
Gecode::Int::LDSB::VariableSequenceSymmetryObject::~VariableSequenceSymmetryObject
~VariableSequenceSymmetryObject()
Destructor.
Definition sym-obj.cpp:101
Gecode::Int::LDSB::VariableSequenceSymmetryObject::nxs
int nxs
Number of variables in symmetry.
Definition ldsb.hh:141
Gecode::Int::LDSB::VariableSequenceSymmetryObject::xs
VarImpBase ** xs
Array of variables in symmetry.
Definition ldsb.hh:139
Gecode::Int::LDSB::VariableSequenceSymmetryObject::VariableSequenceSymmetryObject
VariableSequenceSymmetryObject(ArgArray< VarImpBase * > vars, int ss)
Constructor for creation.
Definition sym-obj.cpp:94
Gecode::Int::LDSB::VariableSymmetryObject::~VariableSymmetryObject
~VariableSymmetryObject(void)
Destructor.
Definition sym-obj.cpp:86
Gecode::Int::LDSB::VariableSymmetryObject::nxs
int nxs
Number of variables in symmetry.
Definition ldsb.hh:121
Gecode::Int::LDSB::VariableSymmetryObject::VariableSymmetryObject
VariableSymmetryObject(ArgArray< VarImpBase * > vars)
Constructor for creation.
Definition sym-obj.cpp:80
Gecode::Int::LDSB::VariableSymmetryObject::xs
VarImpBase ** xs
Array of variables in symmetry.
Definition ldsb.hh:119
Gecode::SymmetryHandle
A reference-counted pointer to a SymmetryObject.
Definition int.hh:5255
Gecode::SymmetryHandle::SymmetryHandle
SymmetryHandle(void)
Default constructor.
Definition sym-obj.cpp:37
Gecode::SymmetryHandle::ref
Int::LDSB::SymmetryObject * ref
Symmetry object that this handle refers to.
Definition int.hh:5258
Gecode::SymmetryHandle::decrement
void decrement(void)
Decrement counter.
Definition sym-obj.cpp:66
Gecode::SymmetryHandle::operator=
const SymmetryHandle & operator=(const SymmetryHandle &h)
Assignment operator.
Definition sym-obj.cpp:47
Gecode::SymmetryHandle::increment
void increment(void)
Increment counter.
Definition sym-obj.cpp:62
Gecode::SymmetryHandle::~SymmetryHandle
~SymmetryHandle(void)
Destructor.
Definition sym-obj.cpp:57
Gecode::VarImpBase
Base-class for variable implementations.
Definition core.hpp:172
ldsb.hh
Gecode
Gecode toplevel namespace