ranges-compl.hpp /usr/include/gecode/iter.hh Gecode::Iter::Ranges::Compl Gecode::Iter::Ranges::ComplVal Gecode Gecode::Iter Gecode::Iter::Ranges /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> *GuidoTack<tack@gecode.org> * *Copyright: *GuidoTack,2004 *ChristianSchulte,2005 * *Lastmodified: *$Date:2010-07-2817:35:33+0200(Wed,28Jul2010)$by$Author:schulte$ *$Revision:11294$ * *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. * */ namespaceGecode{namespaceIter{namespaceRanges{ template<intUMIN,intUMAX,classI> classCompl:publicMinMax{ protected: Ii; voidstart(void); public: Compl(void); Compl(I&i); voidinit(I&i); voidoperator ++(void); }; template<classI> classComplVal:publicMinMax{ protected: intUMIN,UMAX; Ii; voidstart(void); public: ComplVal(void); ComplVal(intumin,intumax,I&i); voidinit(intumin,intumax,I&i); voidoperator ++(void); }; template<intUMIN,intUMAX,classI> forceinlinevoid Compl<UMIN,UMAX,I>::start(void){ if(i()){ assert((i.min()>=UMIN)&&(i.max()<=UMAX)); if(i.min()>UMIN){ mi=UMIN; ma=i.min()-1; }elseif(i.max()<UMAX){ mi=i.max()+1; ++i; ma=i()?(i.min()-1):UMAX; }else{ finish(); } }else{ mi=UMIN; ma=UMAX; } } template<intUMIN,intUMAX,classI> forceinline Compl<UMIN,UMAX,I>::Compl(void){} template<intUMIN,intUMAX,classI> forceinline Compl<UMIN,UMAX,I>::Compl(I&i0):i(i0){ start(); } template<intUMIN,intUMAX,classI> forceinlinevoid Compl<UMIN,UMAX,I>::init(I&i0){ i=i0;start(); } template<intUMIN,intUMAX,classI> forceinlinevoid Compl<UMIN,UMAX,I>::operator ++(void){ assert(!i()||(i.max()<=UMAX)); if(i()&&(i.max()<UMAX)){ mi=i.max()+1; ++i; ma=i()?(i.min()-1):UMAX; }else{ finish(); } } template<classI> forceinlinevoid ComplVal<I>::start(void){ if(i()){ assert((i.min()>=UMIN)&&(i.max()<=UMAX)); if(i.min()>UMIN){ mi=UMIN; ma=i.min()-1; }elseif(i.max()<UMAX){ mi=i.max()+1; ++i; ma=i()?(i.min()-1):UMAX; }else{ finish(); } }else{ mi=UMIN; ma=UMAX; } } template<classI> forceinline ComplVal<I>::ComplVal(void){} template<classI> forceinline ComplVal<I>::ComplVal(intumin,intumax,I&i0) :UMIN(umin),UMAX(umax),i(i0){ start(); } template<classI> forceinlinevoid ComplVal<I>::init(intumin,intumax,I&i0){ UMIN=umin;UMAX=umax;i=i0;start(); } template<classI> forceinlinevoid ComplVal<I>::operator ++(void){ assert(!i()||(i.max()<=UMAX)); if(i()&&(i.max()<UMAX)){ mi=i.max()+1; ++i; ma=i()?(i.min()-1):UMAX; }else{ finish(); } } }}} //STATISTICS:iter-any