00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _TREE_CAN_CODE_
00023 #define _TREE_CAN_CODE_
00024
00025 using namespace std;
00026
00027 #include <string>
00028 #include <sstream>
00029 #include "generic_classes.h"
00030 #include "typedefs.h"
00031
00038 template<typename PP, typename V_T, typename E_T, template <typename> class ALLOC>
00039 class canonical_code<TREE_PROP, V_T, E_T, ALLOC>
00040 {
00041
00042 public:
00043
00044 typedef int STORAGE_TYPE;
00045 typedef V_T INIT_TYPE;
00046 typedef eqint COMPARISON_FUNC;
00047
00048 canonical_code() {}
00049
00050 void backtrack() {
00051 }
00052
00053 template<class PAT>
00054 void init(const INIT_TYPE& v, PAT* pattern) {
00055 typename map<V_T, int>::iterator i;
00056 i = len1_pat_map.find(v);
00057
00058 if(i != len1_pat_map.end())
00059 _can_code = i->second;
00060 else {
00061 len1_pat_map[v] = init_counter;
00062 _can_code = init_counter++;
00063 }
00064
00065 pattern->update_rmpath(0);
00066 }
00067
00068 void insert_vertex(const INIT_TYPE& v) {
00069 }
00070
00071 void update_code() {
00072 _can_code = id_generator--;
00073 }
00074
00075
00076 STORAGE_TYPE getCode() const {
00077 return _can_code;
00078 }
00079
00080 private:
00081 STORAGE_TYPE _can_code;
00082 static int id_generator;
00083 static map<V_T, int> len1_pat_map;
00084 static int init_counter;
00085
00086 };
00087
00088 template<class PP, typename V_T, typename E_T, template <typename> class ALLOC>
00089 int canonical_code<TREE_PROP, V_T, E_T, ALLOC >::id_generator = -1;
00090
00091 template<class PP, typename V_T, typename E_T, template <typename> class ALLOC >
00092 int canonical_code<TREE_PROP, V_T, E_T, ALLOC >::init_counter = 1;
00093
00094 template<class PP, typename V_T, typename E_T, template <typename> class ALLOC >
00095 map<V_T, int> canonical_code<TREE_PROP, V_T, E_T, ALLOC >::len1_pat_map;
00096
00097
00098 #endif