Generated on Tue May 22 09:39:43 2018 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   IntArgs::IntArgs(int n, int e0, ...) : PrimArgArray<int>(n) {
00039     va_list args;
00040     va_start(args, e0);
00041     a[0] = e0;
00042     for (int i = 1; i < n; i++)
00043       a[i] = va_arg(args,int);
00044     va_end(args);
00045   }
00046 
00047   IntVarArray::IntVarArray(Space& home, int n, int min, int max)
00048     : VarArray<IntVar>(home,n) {
00049     Int::Limits::check(min,"IntVarArray::IntVarArray");
00050     Int::Limits::check(max,"IntVarArray::IntVarArray");
00051     if (min > max)
00052       throw Int::VariableEmptyDomain("IntVarArray::IntVarArray");
00053     for (int i = size(); i--; )
00054       x[i]._init(home,min,max);
00055   }
00056 
00057   IntVarArray::IntVarArray(Space& home, int n, const IntSet& s)
00058     : VarArray<IntVar>(home,n) {
00059     Int::Limits::check(s.min(),"IntVarArray::IntVarArray");
00060     Int::Limits::check(s.max(),"IntVarArray::IntVarArray");
00061     if (s.size() == 0)
00062       throw Int::VariableEmptyDomain("IntVarArray::IntVarArray");
00063     for (int i = size(); i--; )
00064       x[i]._init(home,s);
00065   }
00066 
00067   BoolVarArray::BoolVarArray(Space& home, int n, int min, int max)
00068     : VarArray<BoolVar>(home, n) {
00069     if ((min < 0) || (max > 1))
00070       throw Int::NotZeroOne("BoolVarArray::BoolVarArray");
00071     if (min > max)
00072       throw Int::VariableEmptyDomain("BoolVarArray::BoolVarArray");
00073     for (int i = size(); i--; )
00074       x[i]._init(home,min,max);
00075   }
00076 
00077   IntVarArgs::IntVarArgs(Space& home, int n, int min, int max)
00078     : VarArgArray<IntVar>(n) {
00079     Int::Limits::check(min,"IntVarArgs::IntVarArgs");
00080     Int::Limits::check(max,"IntVarArgs::IntVarArgs");
00081     if (min > max)
00082       throw Int::VariableEmptyDomain("IntVarArgs::IntVarArgs");
00083     for (int i = size(); i--; )
00084       a[i]._init(home,min,max);
00085   }
00086 
00087   IntVarArgs::IntVarArgs(Space& home, int n, const IntSet& s)
00088     : VarArgArray<IntVar>(n) {
00089     Int::Limits::check(s.min(),"IntVarArgs::IntVarArgs");
00090     Int::Limits::check(s.max(),"IntVarArgs::IntVarArgs");
00091     if (s.size() == 0)
00092       throw Int::VariableEmptyDomain("IntVarArgs::IntVarArgs");
00093     for (int i = size(); i--; )
00094       a[i]._init(home,s);
00095   }
00096 
00097   BoolVarArgs::BoolVarArgs(Space& home, int n, int min, int max)
00098     : VarArgArray<BoolVar>(n) {
00099     if ((min < 0) || (max > 1))
00100       throw Int::NotZeroOne("BoolVarArgs::BoolVarArgs");
00101     if (min > max)
00102       throw Int::VariableEmptyDomain("BoolVarArgs::BoolVarArgs");
00103     for (int i = size(); i--; )
00104       a[i]._init(home,min,max);
00105   }
00106 
00107 }
00108 
00109 // STATISTICS: int-post