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"); } }
public void Desencolar() { if (head == tail) { head = null; tail = null; return; } head = head.Siguiente; }
public void Encolar(NodoCola n) { if (head == null) { head = n; tail = n; } else { tail.Siguiente = n; tail = n; } }
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(); } }
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; }
public ColaOperaciones() { head = null; tail = null; }