00001 #ifndef wali_PRIORITY_WORKLIST_GUARD 00002 #define wali_PRIORITY_WORKLIST_GUARD 1 00003 00004 /*! 00005 * @author Nicholas Kidd 00006 */ 00007 00008 #include "wali/Common.hpp" 00009 #include "wali/Worklist.hpp" 00010 #include "wali/wfa/Trans.hpp" 00011 #include <map> 00012 #include <set> 00013 00014 namespace wali 00015 { 00016 class PriorityWorklist : public Worklist<wfa::ITrans> 00017 { 00018 private: 00019 struct LessThan { 00020 LessThan( PriorityWorklist& pw ) : pWorklist(pw) {} 00021 00022 PriorityWorklist& pWorklist; 00023 00024 bool operator()( const wfa::ITrans* a, const wfa::ITrans* b ) const 00025 { 00026 return pWorklist.compareTo(a,b) < 0; 00027 } 00028 00029 }; 00030 00031 public: 00032 typedef std::multiset< wfa::ITrans*, LessThan > pwl_t; 00033 00034 public: 00035 PriorityWorklist(); 00036 00037 virtual ~PriorityWorklist(); 00038 00039 virtual bool put( wfa::ITrans *t ); 00040 00041 virtual wfa::ITrans * get(); 00042 00043 virtual bool empty() const; 00044 00045 virtual void clear(); 00046 00047 /* 00048 * Override this for custom sorting. Default is to perform a 00049 * comparison on the Trans's stack key. 00050 */ 00051 virtual int compareTo( const wfa::ITrans* a, const wfa::ITrans* b ) const; 00052 00053 protected: 00054 pwl_t workset; 00055 00056 }; // class PriorityWorklist 00057 00058 } // namespace wali 00059 00060 #endif // wali_PRIORITY_WORKLIST_GUARD 00061