int main() { stringset strset; SetNew(&strset, StringCompare, NULL); assert(SetAdd(&strset, "lion")); assert(SetAdd(&strset, "tiger")); assert(SetAdd(&strset, "bear")); SetAdd(&strset, "dorothy"); SetAdd(&strset, "scarecrow"); SetAdd(&strset, "witch"); SetAdd(&strset, "tin man"); SetAdd(&strset, "wizard"); assert(!SetAdd(&strset, "lion")); assert(!SetAdd(&strset, "tiger")); assert(!SetAdd(&strset, "bear")); SetPrint(&strset); printf("\nSet contains %d elements\n", SetSize(&strset)); char *dorothy = SetSearch(&strset, "dorothy"); char *elphaba = SetSearch(&strset, "elphaba"); printf("\n"); printf("Found dorothy: %s\n", dorothy == NULL ? "no" : "yes"); printf("Found elphaba: %s\n", elphaba == NULL ? "no" : "yes"); SetDestroy(&strset); return 0; }
void CDlgPreAfn0AF7Q::OnOK() { // TODO: Add extra validation here SetNew(); CDialog::OnOK(); }
button::button(particle::type ParticleType): background("button3.bmp"), mouseover("button4.bmp") { SetNew(ParticleType); }
/* Find all nonterminals which will generate the empty string. ** Then go back and compute the first sets of every nonterminal. ** The first set is the set of all terminal symbols which can begin ** a string generated by that nonterminal. */ void FindFirstSets(struct lmno *lmnop) { int i; struct rule *rp; int progress; for(i=0; i<lmnop->nsymbol; i++) { lmnop->symbols[i]->lambda = B_FALSE; } for(i=lmnop->nterminal; i<lmnop->nsymbol; i++) { lmnop->symbols[i]->firstset = SetNew(); } /* First compute all lambdas */ do { progress = 0; for(rp = lmnop->rule; rp; rp = rp->next) { if(rp->lhs->lambda) continue; for(i=0; i<rp->nrhs; i++) { if( rp->rhs[i]->lambda==B_FALSE ) break; } if(i == rp->nrhs) { rp->lhs->lambda = B_TRUE; progress = 1; } } }while( progress ); /* Now compute all first sets */ do { struct symbol *s1, *s2; progress = 0; for(rp = lmnop->rule; rp; rp = rp->next) { s1 = rp->lhs; for(i=0; i<rp->nrhs; i++) { s2 = rp->rhs[i]; if(s2->type == TERMINAL) { progress += SetAdd(s1->firstset,s2->index); break; } else if(s1 == s2) { if(s1->lambda == B_FALSE) break; } else { progress += SetUnion(s1->firstset,s2->firstset); if( s2->lambda==B_FALSE ) break; } } } }while( progress ); return; }