select-val.icc
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 namespace Gecode { namespace Set { namespace Branch {
00029
00030 forceinline int
00031 ValMin::val(const Space*, SetView x) const {
00032 UnknownRanges<SetView> unknown(x);
00033 return unknown.min();
00034 }
00035 forceinline ModEvent
00036 ValMin::tell(Space* home, unsigned int a, SetView x, int v) {
00037 return (a == 0) ? x.include(home,v) : x.exclude(home,v);
00038 }
00039
00040 forceinline int
00041 ValMax::val(const Space*, SetView x) const {
00042 int maxElem = 0;
00043 UnknownRanges<SetView> unknown(x);
00044 while (unknown()) {
00045 maxElem = unknown.max();
00046 ++unknown;
00047 }
00048 return maxElem;
00049 }
00050 forceinline ModEvent
00051 ValMax::tell(Space* home, unsigned int a, SetView x, int v) {
00052 return (a == 0) ? x.include(home,v) : x.exclude(home,v);
00053 }
00054
00055 template <class SelView>
00056 static void
00057 create(Space* home, ViewArray<SetView>& x, SetBvalSel vals) {
00058 switch (vals) {
00059 case SETBVAL_MIN:
00060 (void) new (home) ViewValBranching<SetView,int,SelView,ValMin>(home,x);
00061 break;
00062 case SETBVAL_MAX:
00063 (void) new (home) ViewValBranching<SetView,int,SelView,ValMax>(home,x);
00064 break;
00065 default:
00066 throw UnknownBranching("Set::branch");
00067 }
00068 }
00069
00070 }}}
00071
00072