Generated on Thu Apr 11 13:58:56 2019 for Gecode by doxygen 1.6.3

array.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2002
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #include <gecode/int.hh>
00035 
00036 namespace Gecode {
00037 
00038   IntVarArray::IntVarArray(Space& home, int n, int min, int max)
00039     : VarArray<IntVar>(home,n) {
00040     Int::Limits::check(min,"IntVarArray::IntVarArray");
00041     Int::Limits::check(max,"IntVarArray::IntVarArray");
00042     if (min > max)
00043       throw Int::VariableEmptyDomain("IntVarArray::IntVarArray");
00044     for (int i=0; i<size(); i++)
00045       x[i]._init(home,min,max);
00046   }
00047 
00048   IntVarArray::IntVarArray(Space& home, int n, const IntSet& s)
00049     : VarArray<IntVar>(home,n) {
00050     Int::Limits::check(s.min(),"IntVarArray::IntVarArray");
00051     Int::Limits::check(s.max(),"IntVarArray::IntVarArray");
00052     if (s.size() == 0)
00053       throw Int::VariableEmptyDomain("IntVarArray::IntVarArray");
00054     for (int i=0; i<size(); i++)
00055       x[i]._init(home,s);
00056   }
00057 
00058   BoolVarArray::BoolVarArray(Space& home, int n, int min, int max)
00059     : VarArray<BoolVar>(home, n) {
00060     if ((min < 0) || (max > 1))
00061       throw Int::NotZeroOne("BoolVarArray::BoolVarArray");
00062     if (min > max)
00063       throw Int::VariableEmptyDomain("BoolVarArray::BoolVarArray");
00064     for (int i=0; i<size(); i++)
00065       x[i]._init(home,min,max);
00066   }
00067 
00068   IntVarArgs::IntVarArgs(Space& home, int n, int min, int max)
00069     : VarArgArray<IntVar>(n) {
00070     Int::Limits::check(min,"IntVarArgs::IntVarArgs");
00071     Int::Limits::check(max,"IntVarArgs::IntVarArgs");
00072     if (min > max)
00073       throw Int::VariableEmptyDomain("IntVarArgs::IntVarArgs");
00074     for (int i=0; i<size(); i++)
00075       a[i]._init(home,min,max);
00076   }
00077 
00078   IntVarArgs::IntVarArgs(Space& home, int n, const IntSet& s)
00079     : VarArgArray<IntVar>(n) {
00080     Int::Limits::check(s.min(),"IntVarArgs::IntVarArgs");
00081     Int::Limits::check(s.max(),"IntVarArgs::IntVarArgs");
00082     if (s.size() == 0)
00083       throw Int::VariableEmptyDomain("IntVarArgs::IntVarArgs");
00084     for (int i=0; i<size(); i++)
00085       a[i]._init(home,s);
00086   }
00087 
00088   BoolVarArgs::BoolVarArgs(Space& home, int n, int min, int max)
00089     : VarArgArray<BoolVar>(n) {
00090     if ((min < 0) || (max > 1))
00091       throw Int::NotZeroOne("BoolVarArgs::BoolVarArgs");
00092     if (min > max)
00093       throw Int::VariableEmptyDomain("BoolVarArgs::BoolVarArgs");
00094     for (int i=0; i<size(); i++)
00095       a[i]._init(home,min,max);
00096   }
00097 
00098 }
00099 
00100 // STATISTICS: int-post