Exemple #1
0
//Hash* criaHash()
void insereNaHash(Hash* h, Elemento* x, int type){
  int index = x->matricula % h->tam;
  if(type == 0){
    if(h->hash[index] == NULL){
      h->hash[index] = criaArvore(x);
    }
    else insereElemento(h->hash[index], x);
  }
  if(type == 1){
    if(h->hashSBB == NULL){
      fprintf(stderr, "h->hashSBB is null\n");
    }
    if(h->hashSBB[index] == NULL) {
      h->hashSBB[index] = criaArvoreSBB(x);
    } else insereSBB(&(h->hashSBB[index]), x);
  }
}
//insere um Elemento na Hash
void insereNaHash(Hash* h, Elemento* x, int boolSBB){

	int pos = funcaoHash(x, h);

	if (boolSBB==1){
		if (h->hashSBB[pos]==NULL){
				h->hashSBB[pos] = criaArvoreSBB(x);
		} else{
			insereElementoSBB(&(h->hashSBB[pos]), x);
		}
		h->nElem++;
	}else{
		if (h->hash[pos]==NULL){
			h->hash[pos] = criaArvore(x);
		} else{
			insereElemento(h->hash[pos], x);
		}
		h->nElem++;
	}
}