コード例 #1
0
        public String generarImagenCola()
        {
            String       dot    = "digraph g{\nrankdir=LR\nnode [shape = record, width = 0.1, height = 0.1];\n";
            String       cuerpo = "";
            NodoPilaCola aux    = inicio;

            for (int pos = 0; pos < size; pos++)
            {
                dot += "struct" + pos + " [label = \"{<f0> Suma\\n" + aux.getMatriz().getSuma() +
                       " |<f1> }\"];\n";
                if (pos == 0)
                {
                    cuerpo += "head -> struct0:f0;\n";
                }
                else
                {
                    cuerpo += "struct" + (pos - 1) + ":f1 -> struct" + pos + ":f0;\n";
                }
                aux = aux.getSiguiente();
            }
            dot += cuerpo + "struct" + (size - 1) + ":f1 -> null;\nbottom -> struct" + (size - 1) + ":f0;\n";

            dot += "label = \"Cola\"\n}";
            return(dot);
        }
コード例 #2
0
        public void push(Matriz m)
        {
            NodoPilaCola nuevo = new NodoPilaCola(m);

            nuevo.setSiguiente(inicio);
            inicio = nuevo;
            size++;
        }
コード例 #3
0
        public void queue(Matriz m)
        {
            NodoPilaCola nuevo = new NodoPilaCola(m);

            if (isEmpty())
            {
                inicio = nuevo;
            }
            else
            {
                fin.setSiguiente(nuevo);
            }
            fin = nuevo;
            size++;
        }
コード例 #4
0
        public NodoPilaCola pop()
        {
            NodoPilaCola matrizEliminada;

            if (isEmpty())
            {
                throw new Exception("Excepción: Pila vacía");
            }
            else
            {
                matrizEliminada = inicio;
            }
            inicio = inicio.getSiguiente();
            size--;
            return(matrizEliminada);
        }
コード例 #5
0
        public NodoPilaCola dequeue()
        {
            NodoPilaCola aux;

            if (!isEmpty())
            {
                aux    = inicio;
                inicio = inicio.getSiguiente();
                size--;
            }
            else
            {
                throw new Exception("Excepción: Cola vacía");
            }
            return(aux);
        }
コード例 #6
0
        public String generarImagenPila()
        {
            String dot = "digraph g{\nrankdir=TB;\nnode [shape = record, width = 0.1, height = 0.1];\n";

            dot += "struct [label = \"{";
            NodoPilaCola aux = inicio;

            while (aux != null)
            {
                if (aux == inicio)
                {
                    dot += "<f0> Suma\\n" + aux.getMatriz().getSuma();
                }
                else
                {
                    dot += " | Suma\\n" + aux.getMatriz().getSuma();
                }
                aux = aux.getSiguiente();
            }

            dot += "}\"];\n\nlabel = \"Pila\"\n}";
            return(dot);
        }
コード例 #7
0
 public PilaUsuario()
 {
     this.inicio = null;
     this.size   = 0;
 }
コード例 #8
0
 public void setSiguiente(NodoPilaCola siguiente)
 {
     this.siguiente = siguiente;
 }
コード例 #9
0
 public NodoPilaCola(Matriz matriz)
 {
     this.matriz    = matriz;
     this.siguiente = null;
 }
コード例 #10
0
 public ColaUsuario()
 {
     this.inicio = null;
     this.fin    = null;
     this.size   = 0;
 }