Exemple #1
0
 private void BtnCargar_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog Seleccionar = new OpenFileDialog();
         if (Seleccionar.ShowDialog() == DialogResult.OK)
         {
             MiCola.Head = null;
             int      contador = 0;
             string   ruta     = Seleccionar.FileName;
             string   linea    = File.ReadAllText(ruta);
             string[] Lista    = linea.Split(',');
             foreach (string i in Lista)
             {
                 n      = new NodoCola();
                 n.Dato = int.Parse(Lista[contador]);
                 MiCola.Encolar(n);
                 contador++;
             }
             lblCola.Text = MiCola.ToString();
         }
     }
     catch
     {
         MessageBox.Show("Error al cargar");
     }
 }
Exemple #2
0
 public void Desencolar()
 {
     if (head == tail)
     {
         head = null;
         tail = null;
         return;
     }
     head = head.Siguiente;
 }
Exemple #3
0
 public void Encolar(NodoCola n)
 {
     if (head == null)
     {
         head = n;
         tail = n;
     }
     else
     {
         tail.Siguiente = n;
         tail           = n;
     }
 }
Exemple #4
0
 private void BtnEncolar_Click(object sender, EventArgs e)
 {
     try
     {
         n      = new NodoCola();
         n.Dato = int.Parse(txtNodo.Text);
         MiCola.Encolar(n);
         lblCola.Text = MiCola.ToString();
         txtNodo.Clear();
     }
     catch
     {
         MessageBox.Show("Bruh");
         txtNodo.Clear();
     }
 }
Exemple #5
0
        public override string ToString()
        {
            string   stringCola = "";
            NodoCola h          = head;

            if (h != null)
            {
                stringCola += h.ToString();
                h           = h.Siguiente;
                while (h != null)
                {
                    stringCola += "," + h.ToString();
                    h           = h.Siguiente;
                }
                return(stringCola);
            }
            else
            {
                return("La cola está vacía");
            }
        }
 public NodoCola(int dato, NodoCola siguiente)
 {
     this.dato      = dato;
     this.siguiente = siguiente;
 }
 public NodoCola()
 {
     dato      = 0;
     siguiente = null;
 }
Exemple #8
0
 public ColaOperaciones()
 {
     head = null;
     tail = null;
 }