예제 #1
0
파일: Lista.cs 프로젝트: anaisafonseca/POO
        // este método pressupõe que intEncontrado está na Lista
        public NohLista encontraNoh(int intEncontrado)
        {
            NohLista foundNoh = INICIO;

            while (foundNoh != null)
            {
                if (foundNoh.getData() == intEncontrado)
                {
                    return(foundNoh);
                }
                else
                {
                    foundNoh = foundNoh.getNext();
                }
            }
            return(null);
        }
예제 #2
0
파일: Lista.cs 프로젝트: anaisafonseca/POO
        public void remove(int n)
        {
            NohLista thisPtr = encontraNoh(n);

            if (thisPtr == INICIO) // remover do início da lista
            {
                INICIO = INICIO.getNext();
                INICIO.setPrevio(null);
            }
            else if (thisPtr == FIM) // remover do fim da lista
            {
                FIM = FIM.getPrevio();
                FIM.setNext(null);
            }
            else // remove um elemento do meio da lista
            {
            }
        }