Example #1
0
 public void Push(int _info)
 {
     if (isEmpty())
     {
         topo = new NohPilha(_info);
     }
     else
     {
         NohPilha novoNoh = new NohPilha(_info, topo);
         topo = novoNoh;
     }
 }
Example #2
0
 public void Push_inv(int insertItem)
 {
     if (isEmpty())
     {
         topo = new NohPilha(insertItem);
     }
     else
     {
         NohPilha n = new NohPilha(insertItem, topo);
         topo = n;
     }
 }
Example #3
0
        public int tamanho()
        {
            NohPilha n = topo;
            int      i = 0;

            while (n != null)
            {
                i++;
                n = n.getNext();
            }
            return(i);
        }
Example #4
0
 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");
     }
 }
Example #5
0
 public int Pop_inv()
 {
     if (isEmpty())
     {
         Console.WriteLine("Pilha vazia!");
         return(0);
     }
     else
     {
         int valor = topo.getInfo();
         topo = topo.getNext();
         return(valor);
     }
 }
Example #6
0
 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();
         }
     }
 }
Example #7
0
 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);
     }
 }
Example #8
0
 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);
     }
 }
Example #9
0
 public Pilha()
 {
     topo = null;
 }
Example #10
0
 public void setNext(NohPilha _next)
 {
     next = _next;
 }
Example #11
0
 public NohPilha(int _info, NohPilha _next)
 {
     info = _info;
     next = _next;
 }
Example #12
0
 public NohPilha(int _info)
 {
     info = _info;
     next = null;
 }
Example #13
0
 public NohPilha()
 {
     info = 0;
     next = null;
 }