예제 #1
0
 public void imprimeDE()
 {
     string result = "Lista Atual: ";
     for (NohLista aux = fim; aux != null; aux = aux.getPrevio())
     {
         result += aux.getData() + ((aux != inicio) ? "<-" : "");
     }
     Console.WriteLine(result);
 }
예제 #2
0
 public void remove(int noh)
 {
     bool achou = false;
     if (isEmpty())
     {
         throw new Exception();
     }
     for (NohLista aux = inicio; aux != null; aux = aux.getNext())
     {
         if (aux.getData() == noh)
         {
             if (aux == inicio)
             {
                 inicio = inicio.getNext();
                 inicio.setPrevio(null);
             }
             else if (aux == fim)
             {
                 fim = fim.getPrevio();
                 fim.setNext(null);
             }
             else
             {
                 aux.getPrevio().setNext(aux.getNext());
                 aux.getNext().setPrevio(aux.getPrevio());
             }
             achou = true;
             break;
         }
     }
     if (!achou)
     {
         Console.Error.WriteLine("Item não encontrado");
         throw new Exception();
     }
 }