public void Pop(System.Windows.Forms.RichTextBox tbPop) { try { int valor = topo.getInfo(); topo = topo.getNext(); tbPop.Text = Convert.ToString(valor); } catch (NullReferenceException) { System.Windows.Forms.MessageBox.Show("Pilha vazia!!", "ERRO"); } }
public int tamanho() { NohPilha n = topo; int i = 0; while (n != null) { i++; n = n.getNext(); } return(i); }
public void Print(System.Windows.Forms.RichTextBox tbPilha) { tbPilha.Clear(); if (isEmpty()) { System.Windows.Forms.MessageBox.Show("Pilha vazia!!", "ERRO"); } else { NohPilha n = topo; while (n != null) { tbPilha.AppendText(Convert.ToString(n.getInfo()) + "\n"); n = n.getNext(); } } }
public void Menor(System.Windows.Forms.RichTextBox tbPilha) { if (isEmpty()) { System.Windows.Forms.MessageBox.Show("Pilha vazia!!", "ERRO"); } else { NohPilha n = topo; int menor = topo.getInfo(); while (n != null) { if (menor > n.getInfo()) { menor = n.getInfo(); } n = n.getNext(); } tbPilha.Text = Convert.ToString(menor); } }
public void Inverte(System.Windows.Forms.RichTextBox tbPilha) { if (isEmpty()) { System.Windows.Forms.MessageBox.Show("Pilha vazia!!", "ERRO"); } else { List <int> dados = new List <int>(); NohPilha n = topo; while (n != null) { dados.Add(n.getInfo()); n = n.getNext(); Pop_inv(); } for (int i = 0; i < dados.Count; i++) { Push_inv(dados[i]); } Print(tbPilha); } }