How to generate a dually linked circular list automatically

0

Good, I have a question as I generate a list doubly linked circulate automatically (give me some data and the number of nodes that I must create).

I have the code to enter All, but I do not think this one will help me

public void insertarNodo(Ruleta dato) {
    Nodo nuevo = new Nodo(dato);

    if (cabeza == null) {
        cabeza = nuevo;
    } else {
        Nodo temp = cabeza;
        while (temp.getSiguiente() != cabeza) {
            temp = temp.getSiguiente();
        }
        temp.setSiguiente(nuevo);
        nuevo.setAnterior(temp);
        nuevo.setSiguiente(temp);
        temp.setAnterior(nuevo);
    }
}

Node Class

public class Nodo {

private Ruleta dato;
private Nodo anterior;
private Nodo siguiente;

public Nodo(Ruleta dato) {
    this.dato = dato;
}

public Ruleta getDato() {
    return dato;
}

public void setDato(Ruleta dato) {
    this.dato = dato;
}

public Nodo getAnterior() {
    return anterior;
}

public void setAnterior(Nodo anterior) {
    this.anterior = anterior;
}

public Nodo getSiguiente() {
    return siguiente;
}

public void setSiguiente(Nodo siguiente) {
    this.siguiente = siguiente;
}

}

I have placed the Node class ..

<p:panel header="#{bundle.titulo} #{beanRuleta.listaRuleta.contarNodos()}" id="pnlDatos">
                <p:panelGrid columns="2">
                    <p:outputLabel value="#{bundle.colores}"/>
                    <p:inputText value="#{beanRuleta.nodoMostrar.dato.colores}" maxlength="25"/>
                    <p:outputLabel value="#{bundle.posiciones}"/>
                    <p:inputText value="#{beanRuleta.nodoMostrar.dato.posicion}" maxlength="25"/>

                </p:panelGrid>
            </p:panel>
            <h:panelGroup layout="block" id="pnlBotones">
                <p:commandButton value="#{bundle.btnGuardar}" update="@all" action="#{beanRuleta.guardarRuleta()}" ajax="false"/>
            </h:panelGroup>

The previous one is where I ask for the data (position = nodes to create)

In the Bean class I only have the following

public void guardarRuleta(){

    listaRuleta.insertarNodo(new Ruleta(nodoMostrar.getDato().getColores(), nodoMostrar.getDato().getPosicion()));
    inicializarGrafico();
}
    
asked by Godie F Ruiz 06.11.2017 в 05:39
source

0 answers