node.hh gecode/kernel.hh QHash QString /usr/include/gecode/gist/spacenode.hh Gecode::Gist::NodeAllocatorBase Gecode::Gist::NodeAllocatorBase::Block Gecode::Gist::Node Gecode Gecode::Gist /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthors: *GuidoTack<tack@gecode.org> * *Copyright: *GuidoTack,2006 * *Lastmodified: *$Date:2013-07-0203:35:13+0200(Tue,02Jul2013)$by$Author:tack$ *$Revision:13749$ * *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. * */ #ifndefGECODE_GIST_NODE_HH #defineGECODE_GIST_NODE_HH #include<gecode/kernel.hh> #include<QHash> #include<QString> namespaceGecode{namespaceGist{ classVisualNode; template<classT> classNodeAllocatorBase{ private: staticconstintNodeBlockSize=1<<14; classBlock{ public: Tb[NodeBlockSize]; intbest[NodeBlockSize]; }; Block**b; intn; intcur_b; intcur_t; voidallocate(void); bool_bab; QHash<T*,QString>labels; public: NodeAllocatorBase(boolbab); ~NodeAllocatorBase(void); intallocate(intp); intallocate(Space*root); T*operator [](inti)const; T*best(inti)const; voidsetBest(inti,intb); boolbab(void)const; boolshowLabels(void)const; voidshowLabels(boolb); boolhasLabel(T*n)const; voidsetLabel(T*n,constQString&l); voidclearLabel(T*n); QStringgetLabel(T*n)const; }; classNode{ private: enum{ UNDET,//<Numberofchildrennotdetermined LEAF,//<Leafnode TWO_CHILDREN,//<Nodewithatmosttwochildren MORE_CHILDREN//<Nodewithmorethantwochildren }; void*childrenOrFirstChild; intnoOfChildren; intparent; unsignedintgetTag(void)const; voidsetTag(unsignedinttag); void*getPtr(void)const; intgetFirstChild(void)const; protected: boolisUndetermined(void)const; intgetChild(intn)const; public: typedefNodeAllocatorBase<VisualNode>NodeAllocator; Node(intp,boolfailed=false); intgetParent(void)const; VisualNode*getParent(constNodeAllocator&na)const; VisualNode*getChild(constNodeAllocator&na,intn)const; intgetIndex(constNodeAllocator&na)const; boolisRoot(void)const; voidsetNumberOfChildren(unsignedintn,NodeAllocator&na); unsignedintgetNumberOfChildren(void)const; }; }} #endif //STATISTICS:gist-any