Documente Academic
Documente Profesional
Documente Cultură
#ifndef _HASHTABLE_H_
#define _HASHTABLE_H_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "dog.h"
struct node_s{
char key [32];
int value;
struct node_s *next_node;
};
typedef struct node_s node_t;
struct hashtable_s{
int size;
struct node_s **table;
};
typedef struct hashtable_s hashtable_t;
if (size < 1)
return NULL;
hashtable->size = size;
return hashtable;
}
int h = 0, i;
int len = strlen(key);
char temp[len+1];
-1-
D:\Descargas\baangaritar-mtvelasquezg\baangaritar-mtvelasquezg\etc\hashtable.h jueves, 28 de abril de 2016 8:47 p. m.
break;
h = h + ( ( (int) temp[i] ) * (i+1) );
}
h = h % MAXTABLESIZE;
abs(h);
return h;
}
node_t *new_node;
new_node = malloc( sizeof( node_t ) );
if( new_node == NULL ) {
perror("Error al inicializar el nodo" );
exit(-1);
}
strcpy(new_node->key, key);
new_node->value = value;
return new_node;
}
if (!hashtable->table[index]) {
hashtable->table[index] = new_node;
} else {
-2-
D:\Descargas\baangaritar-mtvelasquezg\baangaritar-mtvelasquezg\etc\hashtable.h jueves, 28 de abril de 2016 8:47 p. m.
while (node != NULL) {
next = node;
node = node->next_node;
free(next);
}
}
}
int i;
FILE *fd;
fd = fopen (path_file, "r");
if(fd == NULL){
perror("Error en fopen()\n");
exit(-1);
}
#endif
-3-