Hash* funcaoHash(int size, int type, FILE* fp){ Hash *h = NULL; h = criaHash(size, type); char *n = (char*)calloc(200, sizeof(char)); int mat; Aluno* a; while((fscanf(fp, "%d %[^\n]s", &mat, n)) != EOF){ a = criaAluno(n, mat); n = (char*)calloc(200, sizeof(char)); insereNaHash(h, a, type); //break; } free(n); return h; }
HASH* rehash(HASH *hash, int *tamanho){ int i,numElementos=0; *tamanho*=2; //Dobra o tamanho HASH *novaHash=malloc(sizeof(HASH)*(*tamanho)); if (novaHash == NULL){ return NULL; } novaHash=criaHash(novaHash, *tamanho); for (i=0; i<(*tamanho/2); i++){ HASH auxiliar=hash[i]; while ( auxiliar!= NULL){ novaHash=insere(novaHash, auxiliar->num, *(&tamanho), &numElementos); auxiliar=auxiliar->prox; } } liberaHash(hash, (*tamanho/2));//Desaloca toda hash hash=novaHash; //hash aponta para novaHash return hash; }