values-bitsetoffset.hpp /usr/include/gecode/iter.hh Gecode::Iter::Values::BitSetOffset Gecode Gecode::Iter Gecode::Iter::Values /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2008 * *Convertedintooffsetversion: *ChristopherMears<chris.mears@monash.edu> * *Lastmodified: *$Date:2013-03-0702:18:29+0100(Thu,07Mar2013)$by$Author:mears$ *$Revision:13455$ * *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<classBS> classBitSetOffset{ protected: constBS&bs; intcur; intlimit; voidmove(void); public: BitSetOffset(constBS&bs); BitSetOffset(constBS&bs,intn,intm); booloperator ()(void)const; voidoperator ++(void); intval(void)const; }; template<classBS> forceinline BitSetOffset<BS>::BitSetOffset(constBS&bs0) :bs(bs0),cur(bs.next(bs0.offset())),limit(bs.offset()+bs.size()){ } template<classBS> forceinline BitSetOffset<BS>::BitSetOffset(constBS&bs0,intn,intm) :bs(bs0), cur(bs.next(n)), limit(std::min(bs.offset()+bs.size(),m+1)){ } template<classBS> forceinlinevoid BitSetOffset<BS>::operator ++(void){ cur=bs.next(cur+1); } template<classBS> forceinlinebool BitSetOffset<BS>::operator ()(void)const{ returncur<limit; } template<classBS> forceinlineint BitSetOffset<BS>::val(void)const{ returnstatic_cast<int>(cur); } }}} //STATISTICS:iter-any