/* Exclusao do elemento de chave indicada */ bool excluirElemLista(TIPOCHAVE ch, LISTA *l){ PONT ant, i; i = buscaSeqExc(ch, l, &ant); if (i == NULL) return false; if (ant == NULL) l->inicio = i->prox; else ant->prox = i->prox; free(i); return true; } /* excluirElemListaEnc */
bool excluir(TIPOCHAVE ch, Lista* l) { Pont ant,i; i = buscaSeqExc(ch,l,&ant); if (i!=NULL) { if(ant==NULL) l->inicio = i->prox; else ant->prox = i->prox; free i; return true; } return false; }
/* Insercao em lista ordenada sem duplicacao */ bool inserirElemListaOrd(REGISTRO reg, LISTA *l) { TIPOCHAVE ch = reg.chave; PONT ant, i; i = buscaSeqExc(ch, l, &ant); if (i != NULL) return false; i = (PONT) malloc(sizeof(REGISTRO)); *i = reg; if (ant == NULL) { // o novo elemento serah o 1o da lista i->prox = l->inicio; l->inicio = i; } else { // insercao apos um elemento ja existente i->prox = ant->prox; ant->prox = i; } return true; } /* inserirElemListaOrd */
bool inserir (REGISTRO reg, Lista* l) { Pont ant,i; i=buscaSeqExc(reg.chave,l,&ant); if(i!=NULL) return false; i = (Pont) malloc(sizeof(REGISTRO)); *i = reg; if (ant == NULL) { i->prox = l->inicio; l->inicio=i; } else { i->prox = ant->prox; ant->prox = i; } return true; }