stack.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Christian Schulte <schulte@gecode.org> 00004 * 00005 * Copyright: 00006 * Christian Schulte, 2003 00007 * 00008 * Last modified: 00009 * $Date: 2005-08-09 21:44:53 +0200 (Tue, 09 Aug 2005) $ by $Author: schulte $ 00010 * $Revision: 2192 $ 00011 * 00012 * This file is part of Gecode, the generic constraint 00013 * development environment: 00014 * http://www.gecode.org 00015 * 00016 * See the file "LICENSE" for information on usage and 00017 * redistribution of this file, and for a 00018 * DISCLAIMER OF ALL WARRANTIES. 00019 * 00020 */ 00021 00022 namespace Gecode { namespace Search { 00023 00024 /* 00025 * Base stack class 00026 * 00027 */ 00028 00029 template <class Node> 00030 void 00031 BaseStack<Node>::reset(void) { 00032 while (!this->empty()) 00033 this->pop().dispose(); 00034 } 00035 00036 00037 00038 /* 00039 * Copying stack class 00040 * 00041 */ 00042 00043 forceinline 00044 CopyStack::CopyStack(void) {} 00045 00046 forceinline void 00047 CopyStack::push(Space* s, unsigned int alt) { 00048 CopyNode sn(s,alt); 00049 Support::DynamicStack<CopyNode>::push(sn); 00050 } 00051 00052 00053 00054 /* 00055 * Recomputation stack class 00056 * 00057 */ 00058 00059 forceinline 00060 ReCoStack::ReCoStack(unsigned int a_d0) : a_d(a_d0) {} 00061 00062 forceinline BranchingDesc* 00063 ReCoStack::push(Space* s, Space* c, unsigned int alt) { 00064 ReCoNode sn(s,c,alt); 00065 Support::DynamicStack<ReCoNode>::push(sn); 00066 return sn.desc(); 00067 } 00068 00069 forceinline bool 00070 ReCoStack::next(FullStatistics& stat) { 00071 // Generate path for next node and return whether node exists. 00072 while (!empty()) { 00073 if (top().rightmost()) { 00074 stat.pop(top().space(),top().desc()); 00075 pop().dispose(); 00076 } else { 00077 top().next(); 00078 return true; 00079 } 00080 } 00081 return false; 00082 } 00083 00084 }} 00085 00086 // STATISTICS: search-any