array.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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