Grafalgo
Library of useful data structures and algorithms
|
00001 00010 #ifndef PARTITION_H 00011 #define PARTITION_H 00012 00013 #include "Adt.h" 00014 00015 namespace grafalgo { 00016 00020 class Partition : public Adt { 00021 public: Partition(int=26,int=0); 00022 ~Partition(); 00023 00024 // common methods 00025 void clear(); 00026 void clear(int); 00027 void resize(int); 00028 void expand(int); 00029 void copyFrom(const Partition&); 00030 00031 index link(index,index); 00032 index find(index); 00033 00034 string& toString(string&) const; 00035 private: 00036 struct pnode { 00037 index p; 00038 int rank; 00039 } *node; 00040 00041 index findroot(int) const; 00042 void makeSpace(int); 00043 void freeSpace(); 00044 }; 00045 00046 inline void Partition::clear(int u) { 00047 node[u].p = u; node[u].rank = 0; 00048 } 00049 00050 } // ends namespace 00051 00052 #endif