final
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
|||||||
GPP = /usr/bin/g++
|
GPP = /usr/bin/g++
|
||||||
OPTS = -Wall -Wno-deprecated -g -std=c++17
|
OPTS = -Wall -Wno-deprecated -O2 -std=c++17
|
||||||
a.out: diccionariocuacs.o cuac.o fecha.o tablahash.o nodo.o arbol.o
|
a.out: diccionariocuacs.o cuac.o fecha.o tablahash.o nodo.o arbol.o
|
||||||
$(GPP) $(OPTS) main.cpp tablahash.o cuac.o fecha.o diccionariocuacs.o nodo.o arbol.o
|
$(GPP) $(OPTS) main.cpp tablahash.o cuac.o fecha.o diccionariocuacs.o nodo.o arbol.o
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
#include "diccionariocuacs.hpp"
|
#include "diccionariocuacs.hpp"
|
||||||
|
|
||||||
DiccionarioCuacs::DiccionarioCuacs(int m) {
|
|
||||||
TablaHash th = TablaHash(m);
|
|
||||||
Arbol arbol = Arbol();
|
|
||||||
this -> tabla = th;
|
|
||||||
}
|
|
||||||
void DiccionarioCuacs::insertar(Cuac nuevo) {
|
void DiccionarioCuacs::insertar(Cuac nuevo) {
|
||||||
Cuac* ref = tabla.insertar(nuevo);
|
Cuac* ref = tabla.insertar(nuevo);
|
||||||
arbol.insertar(ref);
|
arbol.insertar(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiccionarioCuacs::follow(string nombre){
|
void DiccionarioCuacs::follow(string nombre){
|
||||||
cout << "follow " << nombre << endl;
|
cout << "follow " << nombre << endl;
|
||||||
tabla.consultar(nombre);
|
tabla.consultar(nombre);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiccionarioCuacs::last(int n) {
|
void DiccionarioCuacs::last(int n) {
|
||||||
@@ -29,9 +24,5 @@ void DiccionarioCuacs::date(Fecha f1, Fecha f2) {
|
|||||||
arbol.date(f1, f2);
|
arbol.date(f1, f2);
|
||||||
}
|
}
|
||||||
int DiccionarioCuacs::elem() {
|
int DiccionarioCuacs::elem() {
|
||||||
return tabla.elem();
|
return tabla.elem();
|
||||||
}
|
|
||||||
|
|
||||||
DiccionarioCuacs::~DiccionarioCuacs() {
|
|
||||||
delete[] tabla.lista;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ class DiccionarioCuacs {
|
|||||||
TablaHash tabla;
|
TablaHash tabla;
|
||||||
Arbol arbol;
|
Arbol arbol;
|
||||||
public:
|
public:
|
||||||
DiccionarioCuacs(int m);
|
|
||||||
~DiccionarioCuacs();
|
|
||||||
void insertar(Cuac nuevo);
|
void insertar(Cuac nuevo);
|
||||||
void follow(string nombre);
|
void follow(string nombre);
|
||||||
void last(int n);
|
void last(int n);
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@@ -7,8 +7,7 @@
|
|||||||
#include "tablahash.hpp"
|
#include "tablahash.hpp"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// hay que redimensionar dinámicamente
|
DiccionarioCuacs dic;
|
||||||
DiccionarioCuacs dic = DiccionarioCuacs(1000);
|
|
||||||
|
|
||||||
void procesar_pcuac() {
|
void procesar_pcuac() {
|
||||||
Cuac nuevo;
|
Cuac nuevo;
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
#include "tablahash.hpp"
|
#include "tablahash.hpp"
|
||||||
TablaHash::TablaHash(int M) {
|
|
||||||
nElem = 0;
|
|
||||||
this -> M = M;
|
|
||||||
this -> lista = new list<Cuac>[M];
|
|
||||||
}
|
|
||||||
|
|
||||||
TablaHash::TablaHash() {
|
TablaHash::TablaHash() {
|
||||||
}
|
nElem = 0;
|
||||||
|
|
||||||
TablaHash::~TablaHash() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cuac* TablaHash::insertar(Cuac nuevo) {
|
Cuac* TablaHash::insertar(Cuac nuevo) {
|
||||||
@@ -47,7 +39,7 @@ unsigned int TablaHash::h(string clave) {
|
|||||||
for (int i = 0; i < (int) clave.length(); i++) {
|
for (int i = 0; i < (int) clave.length(); i++) {
|
||||||
res = 67 * res + clave[i];
|
res = 67 * res + clave[i];
|
||||||
}
|
}
|
||||||
return res % M;
|
return res % TH_TAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,18 +5,15 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#define TH_TAM 997
|
||||||
class TablaHash {
|
class TablaHash {
|
||||||
private:
|
private:
|
||||||
friend class DiccionarioCuacs;
|
|
||||||
int nElem;
|
int nElem;
|
||||||
int M;
|
int M;
|
||||||
list<Cuac> *lista;
|
list<Cuac> lista[TH_TAM];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TablaHash();
|
TablaHash();
|
||||||
TablaHash(int M);
|
|
||||||
~TablaHash();
|
|
||||||
Cuac* insertar(Cuac nuevo);
|
Cuac* insertar(Cuac nuevo);
|
||||||
void consultar(string nombre);
|
void consultar(string nombre);
|
||||||
unsigned int h(string clave);
|
unsigned int h(string clave);
|
||||||
|
|||||||
Reference in New Issue
Block a user