complement.hpp sstream /usr/include/gecode/set/view.hpp Gecode::Set::LubRanges< ComplementView< View > > Gecode::Set::LubRanges< ComplementView< ComplementView< View > > > Gecode::Set::GlbRanges< ComplementView< View > > Gecode::Set::GlbRanges< ComplementView< ComplementView< View > > > Gecode Gecode::Set /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *GuidoTack<tack@gecode.org> * *Contributingauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *GuidoTack,2004 *ChristianSchulte,2004 * *Lastmodified: *$Date:2011-05-0200:24:42+0200(Mon,02May2011)$by$Author:tack$ *$Revision:11973$ * *ThisfileispartofGecode,thegenericconstraint *developmentenvironment: *http://www.gecode.org * *Permissionisherebygranted,freeofcharge,toanypersonobtaining *acopyofthissoftwareandassociateddocumentationfiles(the *"Software"),todealintheSoftwarewithoutrestriction,including *withoutlimitationtherightstouse,copy,modify,merge,publish, *distribute,sublicense,and/orsellcopiesoftheSoftware,andto *permitpersonstowhomtheSoftwareisfurnishedtodoso,subjectto *thefollowingconditions: * *Theabovecopyrightnoticeandthispermissionnoticeshallbe *includedinallcopiesorsubstantialportionsoftheSoftware. * *THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND, *EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOF *MERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEAND *NONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBE *LIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTION *OFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTION *WITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE. * */ #include<sstream> namespaceGecode{namespaceSet{ template<classView> forceinline ComplementView<View>::ComplementView(void){} template<classView> forceinline ComplementView<View>::ComplementView(View&y) :DerivedView<View>(y){} template<classView> forceinlineModEvent ComplementView<View>::me_negateset(ModEventme){ switch(me){ caseME_SET_LUB:returnME_SET_GLB; caseME_SET_GLB:returnME_SET_LUB; caseME_SET_CLUB:returnME_SET_CGLB; caseME_SET_CGLB:returnME_SET_CLUB; default:returnme; } } template<classView> forceinlinePropCond ComplementView<View>::pc_negateset(PropCondpc){ switch(pc){ casePC_SET_CLUB:returnPC_SET_CGLB; casePC_SET_CGLB:returnPC_SET_CLUB; default:returnpc; } } template<classView> forceinlineunsignedint ComplementView<View>::glbSize(void)const{ returnLimits::card-x.lubSize(); } template<classView> forceinlineunsignedint ComplementView<View>::lubSize(void)const{ returnLimits::card-x.glbSize(); } template<classView> forceinlineunsignedint ComplementView<View>::unknownSize(void)const{ returnlubSize()-glbSize(); } template<classView> forceinlinebool ComplementView<View>::contains(intn)const{returnx.notContains(n);} template<classView> forceinlinebool ComplementView<View>::notContains(intn)const{returnx.contains(n);} template<classView> forceinlineunsignedint ComplementView<View>::cardMin(void)const{ returnLimits::card-x.cardMax(); } template<classView> forceinlineunsignedint ComplementView<View>::cardMax(void)const{ returnLimits::card-x.cardMin(); } template<classView> forceinlineint ComplementView<View>::lubMin(void)const{ GlbRanges<View>lb(x); RangesCompl<GlbRanges<View>>lbc(lb); if(lbc()){ returnlbc.min(); }else{ returnBndSet::MIN_OF_EMPTY; } } template<classView> forceinlineint ComplementView<View>::lubMax(void)const{ GlbRanges<View>lb(x); RangesCompl<GlbRanges<View>>lbc(lb); if(lbc()){ while(lbc())++lbc; returnlbc.max(); }else{ returnBndSet::MAX_OF_EMPTY; } } template<classView> forceinlineint ComplementView<View>::glbMin(void)const{ LubRanges<View>ub(x); RangesCompl<LubRanges<View>>ubc(ub); if(ubc()){ returnubc.min(); }else{ returnBndSet::MIN_OF_EMPTY; } } template<classView> forceinlineint ComplementView<View>::glbMax(void)const{ LubRanges<View>ub(x); RangesCompl<LubRanges<View>>ubc(ub); if(ubc()){ while(ubc())++ubc; returnubc.max(); }else{ returnBndSet::MAX_OF_EMPTY; } } template<classView> forceinlineModEvent ComplementView<View>::cardMin(Space&home,unsignedintc){ if(c<Limits::card) returnme_negateset(x.cardMax(home,Limits::card-c)); returnME_SET_NONE; } template<classView> forceinlineModEvent ComplementView<View>::cardMax(Space&home,unsignedintc){ if(c<Limits::card) returnme_negateset(x.cardMin(home,Limits::card-c)); returnME_SET_NONE; } template<classView> forceinlineModEvent ComplementView<View>::include(Space&home,intc){ returnme_negateset((x.exclude(home,c))); } template<classView> forceinlineModEvent ComplementView<View>::exclude(Space&home,intc){ returnme_negateset((x.include(home,c))); } template<classView> forceinlineModEvent ComplementView<View>::intersect(Space&home,intc){ Iter::Ranges::Singletonsi(c,c); RangesCompl<Iter::Ranges::Singleton>csi(si); returnme_negateset((x.includeI(home,csi))); } template<classView> forceinlineModEvent ComplementView<View>::intersect(Space&home,inti,intj){ Iter::Ranges::Singletonsi(i,j); RangesCompl<Iter::Ranges::Singleton>csi(si); returnme_negateset((x.includeI(home,csi))); } template<classView> forceinlineModEvent ComplementView<View>::include(Space&home,intj,intk){ returnme_negateset(x.exclude(home,j,k)); } template<classView> forceinlineModEvent ComplementView<View>::exclude(Space&home,intj,intk){ returnme_negateset(x.include(home,j,k)); } template<classView> template<classI>ModEvent ComplementView<View>::excludeI(Space&home,I&iter){ returnme_negateset(x.includeI(home,iter)); } template<classView> template<classI>ModEvent ComplementView<View>::includeI(Space&home,I&iter){ returnme_negateset(x.excludeI(home,iter)); } template<classView> template<classI>ModEvent ComplementView<View>::intersectI(Space&home,I&iter){ RangesCompl<I>c(iter); returnme_negateset(x.includeI(home,c)); } template<classView> forceinlinevoid ComplementView<View>::subscribe(Space&home,Propagator&p,PropCondpc, boolschedule){ x.subscribe(home,p,pc_negateset(pc),schedule); } template<classView> forceinlinevoid ComplementView<View>::cancel(Space&home,Propagator&p,PropCondpc){ x.cancel(home,p,pc_negateset(pc)); } template<classView> forceinlinevoid ComplementView<View>::subscribe(Space&home,Advisor&a){ x.subscribe(home,a); } template<classView> forceinlinevoid ComplementView<View>::cancel(Space&home,Advisor&a){ x.cancel(home,a); } template<classView> forceinlinevoid ComplementView<View>::schedule(Space&home,Propagator&p,ModEventme){ returnView::schedule(home,p,me_negateset(me)); } template<classView> forceinlineModEvent ComplementView<View>::me(constModEventDelta&med){ returnme_negateset(View::me(med)); } template<classView> forceinlineModEventDelta ComplementView<View>::med(ModEventme){ returnme_negateset(View::med(me)); } /* *Deltainformationforadvisors * */ template<classView> forceinlineModEvent ComplementView<View>::modevent(constDelta&d){ returnme_negateset(View::modevent(d)); } template<classView> forceinlineint ComplementView<View>::glbMin(constDelta&d)const{ returnx.lubMin(d); } template<classView> forceinlineint ComplementView<View>::glbMax(constDelta&d)const{ returnx.lubMax(d); } template<classView> forceinlinebool ComplementView<View>::glbAny(constDelta&d)const{ returnx.lubAny(d); } template<classView> forceinlineint ComplementView<View>::lubMin(constDelta&d)const{ returnx.glbMin(d); } template<classView> forceinlineint ComplementView<View>::lubMax(constDelta&d)const{ returnx.glbMax(d); } template<classView> forceinlinebool ComplementView<View>::lubAny(constDelta&d)const{ returnx.glbAny(d); } template<classView> classLubRanges<ComplementView<View>>{ private: GlbRanges<View>lb; RangesCompl<GlbRanges<View>>lbc; public: LubRanges(void){} LubRanges(constComplementView<View>&x); voidinit(constComplementView<View>&x); booloperator ()(void)const; voidoperator ++(void); intmin(void)const; intmax(void)const; unsignedintwidth(void)const; }; template<classView> forceinline LubRanges<ComplementView<View>>::LubRanges(constComplementView<View>&s) :lb(s.base()),lbc(lb){} template<classView> forceinlinevoid LubRanges<ComplementView<View>>::init(constComplementView<View>&s){ lb.init(s.base()); lbc.init(lb); } template<classView> forceinlinebool LubRanges<ComplementView<View>>::operator()(void)const{returnlbc();} template<classView> forceinlinevoid LubRanges<ComplementView<View>>::operator++(void){return++lbc;} template<classView> forceinlineint LubRanges<ComplementView<View>>::min(void)const{returnlbc.min();} template<classView> forceinlineint LubRanges<ComplementView<View>>::max(void)const{returnlbc.max();} template<classView> forceinlineunsignedint LubRanges<ComplementView<View>>::width(void)const{returnlbc.width();} template<classView> classLubRanges<ComplementView<ComplementView<View>>>: publicLubRanges<View>{ public: LubRanges(void){} LubRanges(constComplementView<ComplementView<View>>&x); voidinit(constComplementView<ComplementView<View>>&x); }; template<classView> forceinline LubRanges<ComplementView<ComplementView<View>>>:: LubRanges(constComplementView<ComplementView<View>>&x): LubRanges<View>(x){} template<classView> forceinlinevoid LubRanges<ComplementView<ComplementView<View>>>:: init(constComplementView<ComplementView<View>>&x){ LubRanges<View>::init(x); } template<classView> classGlbRanges<ComplementView<View>>{ private: LubRanges<View>ub; RangesCompl<LubRanges<View>>ubc; public: GlbRanges(void){} GlbRanges(constComplementView<View>&x); voidinit(constComplementView<View>&x); booloperator ()(void)const; voidoperator ++(void); intmin(void)const; intmax(void)const; unsignedintwidth(void)const; }; template<classView> forceinline GlbRanges<ComplementView<View>>::GlbRanges(constComplementView<View>&s) :ub(s.base()),ubc(ub){} template<classView> forceinlinevoid GlbRanges<ComplementView<View>>::init(constComplementView<View>&s){ ub.init(s.base()); ubc.init(ub); } template<classView> forceinlinebool GlbRanges<ComplementView<View>>::operator()(void)const{returnubc();} template<classView> forceinlinevoid GlbRanges<ComplementView<View>>::operator++(void){return++ubc;} template<classView> forceinlineint GlbRanges<ComplementView<View>>::min(void)const{returnubc.min();} template<classView> forceinlineint GlbRanges<ComplementView<View>>::max(void)const{returnubc.max();} template<classView> forceinlineunsignedint GlbRanges<ComplementView<View>>::width(void)const{returnubc.width();} template<classView> classGlbRanges<ComplementView<ComplementView<View>>>: publicGlbRanges<View>{ public: GlbRanges(void){} GlbRanges(constComplementView<ComplementView<View>>&x); voidinit(constComplementView<ComplementView<View>>&x); }; template<classView> forceinline GlbRanges<ComplementView<ComplementView<View>>>:: GlbRanges(constComplementView<ComplementView<View>>&x): GlbRanges<View>(x){} template<classView> forceinlinevoid GlbRanges<ComplementView<ComplementView<View>>>:: init(constComplementView<ComplementView<View>>&x){ GlbRanges<View>::init(x); } template<classChar,classTraits,classView> std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>&os, constComplementView<View>&x){ std::basic_ostringstream<Char,Traits>s; s.copyfmt(os);s.width(0); s<<"("<<x.base()<<")^C"; returnos<<s.str(); } }} //STATISTICS:set-var