values-positive.hpp /usr/include/gecode/iter.hh Gecode::Iter::Values::Positive Gecode Gecode::Iter Gecode::Iter::Values /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2008 * *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{namespaceValues{ template<classI,boolstrict=false> classPositive{ protected: Ii; public: Positive(void); Positive(I&i); voidinit(I&i); booloperator ()(void)const; voidoperator ++(void); intval(void)const; }; template<classI,boolstrict> forceinline Positive<I,strict>::Positive(void){} template<classI,boolstrict> forceinlinevoid Positive<I,strict>::init(I&i0){ i=i0; if(strict){ while(i()&&(i.val()<=0))++i; }else{ while(i()&&(i.val()<0))++i; } } template<classI,boolstrict> forceinline Positive<I,strict>::Positive(I&i0):i(i0){ if(strict){ while(i()&&(i.val()<=0))++i; }else{ while(i()&&(i.val()<0))++i; } } template<classI,boolstrict> forceinlinevoid Positive<I,strict>::operator ++(void){ ++i; } template<classI,boolstrict> forceinlinebool Positive<I,strict>::operator ()(void)const{ returni(); } template<classI,boolstrict> forceinlineint Positive<I,strict>::val(void)const{ returni.val(); } }}} //STATISTICS:iter-any