Go to the documentation of this file.00001 #ifndef wali_DEFAULT_WORKLIST_GUARD
00002 #define wali_DEFAULT_WORKLIST_GUARD 1
00003
00004
00005
00006
00007
00008 #include "wali/Common.hpp"
00009 #include "wali/Worklist.hpp"
00010 #include <list>
00011
00012 namespace wali
00013 {
00014
00015
00016
00017
00018
00019
00020 template< typename T > class DefaultWorklist : public ::wali::Worklist<T>
00021 {
00022 public:
00023
00024 DefaultWorklist() : Worklist<T>() {}
00025
00026 virtual ~DefaultWorklist() {
00027 clear();
00028 }
00029
00030
00031
00032
00033
00034 virtual bool put( T *item ) {
00035 if( !item->marked() ) {
00036 item->mark();
00037 wl.push_back( item );
00038 return true;
00039 }
00040 else
00041 return false;
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 virtual T * get() {
00054 if( !empty() ) {
00055 T *item = wl.back();
00056 wl.pop_back();
00057 item->unmark();
00058 return item;
00059 }
00060 else
00061 return 0;
00062 }
00063
00064
00065
00066
00067
00068
00069 virtual bool empty() const {
00070 return wl.empty();
00071 }
00072
00073
00074
00075
00076
00077
00078 virtual void clear() {
00079 typename std::list< T* >::iterator it = wl.begin();
00080
00081
00082 for( ; it != wl.end() ; it++ ) {
00083 T * item = *it;
00084 item->unmark();
00085 }
00086
00087 wl.clear();
00088 }
00089
00090 protected:
00091 std::list< T* > wl;
00092
00093 };
00094
00095 }
00096
00097 #endif // wali_DEFAULT_WORKLIST_GUARD
00098