I have a method that removes nodes from a list until it is empty. What I need is that after I empty it, I add the elements that I removed to a new list. Here is the method:
public void vaciarD(){
while(!estaVacia()){ //mientras que la lista no esté vacía seguirá eliminando nodos
eliminarInicio(); //metodo para quitar nodos de la lista
}
I tried to do this but my program was cycled and no longer answered:
public void vaciarD(){
while(!estaVacia()){
agregarAlFinal2(eliminarInicio()); //mandar como parametro el nodo eliminado
}
}
In JavaFX, the person in charge of executing the method is:
public void vaciarD(ActionEvent e){
if(list.estaVacia()){
JOptionPane.showMessageDialog(null, "No hay registros de peliculas.");
}else{
list.vaciarD();
txttdisponibles.setText(String.valueOf(list.verTam()));
}
}
Method of addingAlFinal2:
public void agregarAlFinal2(Peliculas dato){
if(! estaVacia()){
fin = new NodoDoble(dato, null, fin);
fin.anterior.siguiente = fin;
}else{
inicio = fin = new NodoDoble(dato);
}
tamanio2 ++;
}
Delete methodHome:
public Peliculas eliminarInicio(){
Peliculas elemento = inicio.dato;
if(inicio == fin){
inicio = fin = null;
}else{
inicio = inicio.siguiente;
inicio.anterior = null;
}
tamanio--;
return elemento;
}