Example #1
0
 public void Push(TAD insertItem)
 {
     if (isEmpty())
     {
         topo = new NohPilha <TAD>(insertItem);
     }
     else
     {
         NohPilha <TAD> n = new NohPilha <TAD>(insertItem, topo);
         topo = n; //n pode ser substituido por this
     }
 }
Example #2
0
 public TAD Pop()
 {
     if (isEmpty())
     {
         Console.WriteLine("Pilha vazia!");
         throw new Exception();
     }
     else
     {
         TAD valor = topo.getData();
         topo = topo.getNextNoh();
         return(valor);
     }
 }
Example #3
0
 public void Print()
 {
     if (isEmpty())
     {
         Console.WriteLine("Pilha vazia!");
     }
     else
     {
         NohPilha <TAD> n = topo;
         while (n != null)
         {
             Console.WriteLine("\n " + n.getData());
             n = n.getNextNoh();
         }
     }
 }
Example #4
0
 public Pilha()
 {
     topo = null;
 }
Example #5
0
 public void setNextNoh(NohPilha <TAD> _nextNoh)
 {
     nextNoh = _nextNoh;
 }
Example #6
0
 public NohPilha(TAD _data, NohPilha <TAD> _nextNoh)
 {
     data    = _data;
     nextNoh = _nextNoh;
 }
Example #7
0
 public NohPilha(TAD _data)
 {
     data    = _data;
     nextNoh = null;
 }
Example #8
0
 public NohPilha()
 {
     nextNoh = null;
 }