void InitListVF(Attribute * item) { InitEmptyListVF(item); int nextNextInstruction = nextIntruction + 1; insereNoFim(&item->listV, &nextIntruction); insereNoFim(&item->listF, &nextNextInstruction); }
void Merge(Lista * dest, Lista * source1, Lista * source2) { int node; while(!listaVazia(source1)) { removeDoInicio(source1, &node); insereNoFim(dest, &node); } while(!listaVazia(source2)) { removeDoInicio(source2, &node); insereNoFim(dest, &node); } }
void carregaLista(pLDDE pListaVertical,int *oi){ char buffer[2000], aux[99]; int offset; int x=0,y=0; FILE *arquivo = fopen("arquivo.txt", "r"); // Abre o arquivo de texto if(arquivo == NULL) // Se falhou abrir o arquivo printf("Erro ao abrir arquivo!"); else { while(!feof(arquivo)) // Enquanto nao chegar no final do texto { Palavra c; pLDDE pListaHorizontal; y++; x=0; cria(&pListaHorizontal, sizeof(Palavra)); //cria segunda lista, está vai possuir struct com as palavras e posicoes fgets(buffer, sizeof(buffer), arquivo); // Le as palavras na linha e guarda na string char *pBuffer = buffer; // Ponteiro para o buffer, para poder mover o ponteiro na hora de ler as palavras while (sscanf(pBuffer,"%s%n", aux, &offset) == 1){ // Le palavra por palavra ate chegar ao final da linha //printf("%s %d\n", aux, offset); c.x=x; c.y=y; *oi=y; pBuffer += offset; // Aponta o ponteiro para a proxima palavra if(x==0) x+= offset+1; else x+= offset; strcpy(c.palavra,aux); insereNoFim(pListaHorizontal, &c); // printf("%s\n",c.palavra); } insereNoFim(pListaVertical, &pListaHorizontal);//indexa pListaHorizontal na lista vertical } } fclose(arquivo); }
int MergeLists(Lista * dest, Lista * source1, Lista * source2) { if(dest == source1 || dest == source2) { return ERRO_MESMA_LISTA; } int node; while(!listaVazia(source1)) { removeDoInicio(source1, &node); insereNoFim(dest, &node); } while(!listaVazia(source2)) { removeDoInicio(source2, &node); insereNoFim(dest, &node); } return 1; }
int passaLista(Lista * dest, Lista * fonte) { if(dest == fonte) { return ERRO_MESMA_LISTA; } int no; while (!listaVazia(fonte)){ removeDoInicio(fonte, &no); insereNoFim(dest, &no); } return 1; }
void InsertIDtable(Lista *IDlist, int type) { if(listaVazia(&IDtable)) InitLista(&IDtable, sizeof(tableNode)); tableNode aux; while(removeDoInicio(IDlist, aux.id) == 1) { if(elementoExiste(IDlist, aux.id, CompareID)) { printf("<Error> in InsertIDtable(Lista *IDlist, int type)\n"); exit(0); } else { static int i = 0; aux.pos = ++i; aux.type = type; insereNoFim(&IDtable, &aux); } } }
void AddToFormParameters(Attribute * item, int argument) { Lista * pItem = &item->formArguments; insereNoFim(pItem, &argument); }