void remover(Lista* lista, Node* noRemover){ if(noRemover != NULL){ if(lista->pPrimeiro == lista->pUltimo){ removerLenUm(lista); }else if(noRemover == lista->pPrimeiro){ removerPrimeiro(lista, noRemover); }else if(noRemover == lista->pUltimo){ removerUltimo(lista, noRemover); }else { noRemover->pAnt->pProx = noRemover->pProx; noRemover->pProx->pAnt = noRemover->pAnt; } free(noRemover); lista->qtde --; } }
QuadroPagina* removerPorID (Lista * lst, int posicao) { QuadroPagina * retorno; No * node,*ant,*prox; int i = 0; if (lst->tam == 0) retorno = NULL; else { if (posicao >= lst->tam) { printf("LIST: Index out of bound \n"); exit(0); } if (posicao == 0) retorno = removerPrimeiro(lst); else { if (posicao == lst->tam-1) retorno = removerUltimo(lst); else { node = lst->prim; while (i < posicao) { node = node->prox; i++; } ant = node->ant; prox = node->prox; ant->prox = prox; prox->ant = ant; retorno = node->info; free(node); lst->tam--; } } } return retorno; }
void limparLista (Lista * lst) { while(lst->tam > 0) removerPrimeiro(lst); }