Example #1
0
 public void remove(T noh)
 {
     try
     {
         NohLista <T> aux = encontraNoh(noh);
         if (aux == inicio && aux == fim)
         {
             inicio = fim = null;
         }
         else 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());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #2
0
        public void insereFim(T data)
        {
            NohLista <T> noh = new NohLista <T>(data);

            if (estaVazia())
            {
                inicio = fim = noh;
            }
            else
            {
                fim.setNext(noh);
                noh.setPrevio(fim);
                fim = noh;
            }
        }
Example #3
0
        public void insereInicio(T data)
        {
            NohLista <T> noh = new NohLista <T>(data);

            if (estaVazia())
            {
                inicio = fim = noh;
            }
            else
            {
                inicio.setPrevio(noh);
                noh.setNext(inicio);
                inicio = noh;
            }
        }