00001
00015 #include <set>
00016 #include <string>
00017 #include <vector>
00018
00019 #if !defined(NodoTrieS_hpp)
00020
00021 #define NodoTrieS_hpp
00022
00023 using namespace std;
00024
00025 #include "Pos.hpp"
00026
00035 class NodoTrieS
00036 {
00037
00038 private:
00039 string cad;
00040 NodoTrieS *hermano_mayor;
00041 NodoTrieS *hijo_menor;
00042 set<Pos> cpos;
00043
00044 friend NodoTrieS *mezcla(NodoTrieS *a1, NodoTrieS *a2);
00045 friend unsigned long precalcula_escribe_actual(NodoTrieS *n);
00046 friend unsigned long precalcula_escribe_con_hermanos(NodoTrieS *n);
00047 friend unsigned long precalcula_escribe(NodoTrieS *n);
00048 friend void escribePlanoStream (NodoTrieS *n,
00049 iostream &os, long desp = 0);
00050 friend class TrieSDiscoCasoPrueba;
00051 friend long escribeCopiaNodoRam(iostream &os, NodoTrieS *a,
00052 NodoTrieS **phijo,
00053 vector<long>* renum);
00054 friend long escribeCopiaSubarbolRam(iostream &os, NodoTrieS *a,
00055 int saltacad,
00056 bool conHermanos,
00057 vector<long>* renum);
00058 friend long mezclaDiscoRam(istream &is1, NodoTrieS *a2,
00059 int saltacad,
00060 iostream &os, bool conHermanos1,
00061 bool conHermanos2,
00062 vector<long> *renum1,
00063 vector<long> *renum2);
00064 friend long escribeCopiaNodoRam(iostream &os, NodoTrieS *a,
00065 int saltacad,
00066 NodoTrieS **phijo,
00067 vector<long>* renum);
00068 public:
00077 NodoTrieS(string cad = "", NodoTrieS *hijo_menor=NULL,
00078 NodoTrieS *hermano_mayor = NULL,
00079 set<Pos> cpos = set<Pos>());
00080
00090 NodoTrieS(string cad, NodoTrieS *hijo_menor,
00091 NodoTrieS *hermano_mayor, Pos p);
00092
00096 ~NodoTrieS();
00097
00101 set<Pos> depuracpos()
00102 {
00103 return cpos;
00104 }
00105
00111 set<Pos> busca(string pal);
00112
00121 void inserta(string pal, Pos p);
00122
00131 void aDotty(ostream &os, string pref = "",
00132 bool primero = true, bool mayor = true);
00133
00138 string preorden();
00139
00145 void NodoTrieS::renumeraDocs(vector<long> renum);
00146
00156 void NodoTrieS::insertaConEtiqueta(string c, string etiqueta,
00157 long numdoc, long pini);
00158
00159 };
00160
00161
00168 void leeTexto(const char *na, long ndoc, NodoTrieS &t,
00169 bool normalizaPal = true);
00170
00171
00172 #endif