values-unique.hpp /usr/include/gecode/iter.hh Gecode::Iter::Values::Unique Gecode Gecode::Iter Gecode::Iter::Values /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2007 * *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> classUnique{ protected: Ii; public: Unique(void); Unique(I&i); voidinit(I&i); booloperator ()(void)const; voidoperator ++(void); intval(void)const; }; template<classI> forceinline Unique<I>::Unique(void){} template<classI> forceinline Unique<I>::Unique(I&i0) :i(i0){} template<classI> forceinlinevoid Unique<I>::init(I&i0){ i=i0; } template<classI> forceinlinevoid Unique<I>::operator ++(void){ intn=i; do{ ++i; }while(i()&&(i.val()==n)); } template<classI> forceinlinebool Unique<I>::operator ()(void)const{ returni(); } template<classI> forceinlineint Unique<I>::val(void)const{ returni.val(); } }}} //STATISTICS:iter-any