int.hpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2002
*
* 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.
*
*/
namespace Gecode {
forceinline void
IntVar::_init(Space& home, int min, int max) {
x = new (home) Int::IntVarImp(home,min,max);
}
forceinline void
IntVar::_init(Space& home, const IntSet& ds) {
x = new (home) Int::IntVarImp(home,ds);
}
forceinline
IntVar::IntVar(void) {}
forceinline
IntVar::IntVar(const IntVar& y)
: VarImpVar<Int::IntVarImp>(y.varimp()) {}
forceinline
IntVar::IntVar(const Int::IntView& y)
: VarImpVar<Int::IntVarImp>(y.varimp()) {}
forceinline int
IntVar::val(void) const {
if (!x->assigned())
throw Int::ValOfUnassignedVar("IntVar::val");
return x->val();
}
forceinline int
IntVar::min(void) const {
return x->min();
}
forceinline int
IntVar::med(void) const {
return x->med();
}
forceinline int
IntVar::max(void) const {
return x->max();
}
forceinline unsigned int
IntVar::width(void) const {
return x->width();
}
forceinline unsigned int
IntVar::size(void) const {
return x->size();
}
forceinline unsigned int
IntVar::regret_min(void) const {
return x->regret_min();
}
forceinline unsigned int
IntVar::regret_max(void) const {
return x->regret_max();
}
forceinline bool
IntVar::range(void) const {
return x->range();
}
forceinline bool
IntVar::in(int n) const {
return x->in(n);
}
/*
* Range iterator
*
*/
forceinline
IntVarRanges::IntVarRanges(void) {}
forceinline
IntVarRanges::IntVarRanges(const IntVar& x)
: Int::IntVarImpFwd(x.varimp()) {}
forceinline void
IntVarRanges::init(const IntVar& x) {
Int::IntVarImpFwd::init(x.varimp());
}
/*
* Value iterator
*
*/
forceinline
IntVarValues::IntVarValues(void) {}
forceinline
IntVarValues::IntVarValues(const IntVar& x) {
IntVarRanges r(x);
Iter::Ranges::ToValues<IntVarRanges>::init(r);
}
forceinline void
IntVarValues::init(const IntVar& x) {
IntVarRanges r(x);
Iter::Ranges::ToValues<IntVarRanges>::init(r);
}
}
// STATISTICS: int-var
Gecode::IntSet
Integer sets.
Definition int.hh:174
Gecode::IntVarRanges
Range iterator for integer variables
Definition int.hh:473
Gecode::IntVarRanges::IntVarRanges
IntVarRanges(void)
Default constructor.
Definition int.hpp:106
Gecode::IntVarRanges::init
void init(const IntVar &x)
Initialize with ranges for integer variable x.
Definition int.hpp:113
Gecode::IntVarValues::IntVarValues
IntVarValues(void)
Default constructor.
Definition int.hpp:124
Gecode::IntVarValues::init
void init(const IntVar &x)
Initialize with values x.
Definition int.hpp:133
Gecode::IntVar
Integer variables.
Definition int.hh:371
Gecode::IntVar::size
unsigned int size(void) const
Return size (cardinality) of domain.
Definition int.hpp:80
Gecode::IntVar::regret_max
unsigned int regret_max(void) const
Return regret of domain maximum (distance to next smaller value).
Definition int.hpp:88
Gecode::IntVar::min
int min(void) const
Return minimum of domain.
Definition int.hpp:62
Gecode::IntVar::val
int val(void) const
Return assigned value.
Definition int.hpp:56
Gecode::IntVar::IntVar
IntVar(void)
Default constructor.
Definition int.hpp:47
Gecode::IntVar::in
bool in(int n) const
Test whether n is contained in domain.
Definition int.hpp:97
Gecode::IntVar::width
unsigned int width(void) const
Return width of domain (distance between maximum and minimum).
Definition int.hpp:76
Gecode::IntVar::range
bool range(void) const
Test whether domain is a range.
Definition int.hpp:93
Gecode::IntVar::regret_min
unsigned int regret_min(void) const
Return regret of domain minimum (distance to next larger value).
Definition int.hpp:84
Gecode::IntVar::med
int med(void) const
Return median of domain (greatest element not greater than the median).
Definition int.hpp:66
Gecode::IntVar::max
int max(void) const
Return maximum of domain.
Definition int.hpp:70
Gecode::Int::IntVarImpFwd::init
void init(const IntVarImp *x)
Initialize with ranges from variable implementation x.
Definition int.hpp:432
Gecode::Int::IntVarImpFwd::IntVarImpFwd
IntVarImpFwd(void)
Default constructor.
Definition int.hpp:427
Gecode::Int::IntVarImp
Integer variable implementation.
Definition var-imp.hpp:89
Gecode::Int::IntView
Integer view for integer variables.
Definition view.hpp:129
Gecode::Int::ValOfUnassignedVar
Exception: Attempt to access value of unassigned variable
Definition exception.hpp:122
Gecode::Iter::Ranges::ToValues::init
void init(I &i)
Initialize with values from range iterator i.
Definition ranges-values.hpp:103
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::VarImpVar< Int::IntVarImp >::varimp
Int::IntVarImp * varimp(void) const
Definition var.hpp:96
Gecode::VarImpVar< Int::IntVarImp >::x
Int::IntVarImp * x
Definition var.hpp:50
Gecode::VarImpVar< Int::IntVarImp >::VarImpVar
VarImpVar(void)
Definition var.hpp:88
Gecode::Int
Finite domain integers.
Gecode
Gecode toplevel namespace
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:67
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:49
forceinline
#define forceinline
Definition config.hpp:187