Grafalgo
Library of useful data structures and algorithms
|
00001 00009 #ifndef LLHEAPSET_H 00010 #define LLHEAPSET_H 00011 00012 #include "LheapSet.h" 00013 #include "List.h" 00014 00015 namespace grafalgo { 00016 00017 typedef bool (*delftyp)(index); 00018 typedef int lheap; 00019 00026 class LlheapSet : public LheapSet { 00027 public: LlheapSet(int=26,delftyp=NULL); 00028 ~LlheapSet(); 00029 00030 // common methods 00031 void clear(); 00032 void resize(int); 00033 void expand(int); 00034 void copyFrom(const LlheapSet&); 00035 00036 index findmin(lheap); 00037 lheap lmeld(lheap,lheap); 00038 lheap insert(index,lheap); 00039 00040 lheap makeheap(List&); 00041 00042 string& toString(string&) const; 00043 string& heap2string(index,string&) const; 00044 private: 00045 int dummy; 00046 delftyp delf; 00047 List *tmplst; 00048 void purge(lheap,List&); 00049 lheap heapify(List&); 00050 00051 string& heap2string(index,bool,string&) const; 00052 void makeSpace(int); 00053 void freeSpace(); 00054 }; 00055 00061 inline string& LlheapSet::heap2string(lheap h, string& s) const { 00062 return heap2string(h,true,s); 00063 } 00064 00065 } // ends namespace 00066 00067 #endif