Esempio n. 1
0
void triRapideFT(TabNombres tn){
  Pile p;
  initPile(&p);
  empile(&p, tn);
  pthread_t thd;
  printf("haha\n");
  int i;
  for(i = 0; i < NBWORKERS; i++){
    pthread_create(&thd, NULL, (void* (*)(void*))worker, (void*)&p);
  }

  //sleep(2);
  //stop = true;
  pthread_join(thd, NULL);
}
Esempio n. 2
0
int empiler(pile* p, int v) {
    // Si la pile n'existe pas encore
    if (!p) return -1;

    if (!*p) *p = initPile();

    list newNode = newSingletonList(v);

    if (!newNode) return -1;

    newNode->prev = (*p)->top;
    if ((*p)->top) (*p)->top->succ = newNode;
    (*p)->top = newNode;
    (*p)->depth++;

    return 1;
}
Esempio n. 3
0
void getMaxRectangle(u8* data, u8 val, int w, int h, vect2D* pos, vect2D* size)
{
	int x;
	vect2D originb=vect2(0,0),cornerb=vect2(-1,-1);
	pile_struct p;
	initPile(&p);
	int* c=initCache(h);
	for(x=w-1;x>=0;x--)
	{
		int y, width=0;
		fillCache(c,data,val,w,h,x);
		for(y=0;y<=h;y++)
		{
			if(c[y]>width)
			{
				pushPile(vect2(y,width),&p);
				width=c[y];
			}else if(c[y]<width)
			{
				int y0, w0;
				while(1)
				{
					vect2D v=popPile(&p);
					y0=v.x;w0=v.y;
					if(width*(y-y0)>area(originb,cornerb))
					{
						originb=vect2(x,y0);
						cornerb=vect2(x+width-1,y-1);
					}
					width=w0;
					if(c[y]>=width)break;
				}
				width=c[y];
				if(width)pushPile(vect2(y0,w0),&p);
			}
		}
	}
	if(c)free(c);
	*pos=originb;
	*size=vect2(cornerb.x-originb.x+1,cornerb.y-originb.y+1);
}
Arbre* constArbre(Elm* t, int n)
{
	/*Transformation de forme infixée au forme postfixée*/
	Pile *p;
	initPile(&p);
	p = infexeeAuPostfixee(t, n);
	/*création de l'arbre*/
	Arbre* f;
	Arbre* f1;
	Arbre* f2;
	/*initialiser la pile des Arbres*/
	PileAebre* pArbre;
	initPileA(&pArbre);

	Elm x;
	while(!pileVide(p))
	{
		depiler(&p, &x);
		if(operande(x))
		{
			f = creatFeuil(x);
			empilerA(&pArbre, f);
		}
		else
		{
			/*construire une sous arbre*/
			f = creatFeuil(x);
			depilerA(&pArbre, &f1);
			depilerA(&pArbre, &f2);
			f->succ_d = f1;
			f->succ_g = f2;
			empilerA(&pArbre, f);
		}
	}
	/*la racine de l'arbre se trouve a la pile des arbres et la pile p est vide*/
	return sommetPileA(pArbre);
}