Last active
February 16, 2019 02:46
-
-
Save Hikhuj/54a103a4c9698e12d1bb45275282ff78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Practica 2: public void elimina (int year) | |
public void elimina(int anio){ | |
Nodo aux = cabeza; | |
// Si ELIMINAR primer dato | |
if(anio == aux.getDato().getAnios()){ | |
cabeza = aux.getNext(); | |
aux = null; | |
} | |
} | |
//Practica 2.1: Elimina ultimo dato | |
public void elimina(int anio) { | |
Nodo aux = cabeza; | |
// Si ELIMINA ultimo dato | |
if(anio == aux.getNext().getDato().getAnios() && aux.getNext().getNext() == null){ | |
cabeza.setNext(null); | |
} | |
} | |
// Practica 2.3: Elimina dato del medio | |
public void elimina(int anio) { | |
Nodo aux = cabeza; | |
// Si ELIMINA ultimo dato | |
while(aux.getNext() != null) { | |
if(anio == aux.getNext().getDato().getAnios() && aux.getNext().getNext() != null){ | |
Nodo tmp = aux.getNext().getNext(); | |
aux.setNext(tmp); | |
}else{ | |
aux = aux.getNext(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment