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++;
	}
}
Exemple #3
0
void query4(){
	ListaLigada l = NULL, prod = NULL;
	int i, j, flag = 0;

    imprimeNumQuery(4);

	for(i = 0; i < 26; i++){
		prod = produtosParaLista(prod, produtos[i]);
	}

	while(prod){
		for(j = 0; j < 12; j++){
			if(!produtoFoiComprado(contas[j],prod->codigo)){
				flag++;
			}
		}
		if(flag == 12) l = insereElemento(l, prod->codigo);
		flag = 0;
		prod = prod->prox;
	}

	if(l != NULL) imprimeLista(l);
}