Example #1
0
        public int pop()
        {
            if (isEmpty())
            {
                throw new Exception();
            }
            int aux = topo.getData();

            topo = topo.getNext();
            count--;
            return(aux);
        }
Example #2
0
        public int pop()
        {
            int aux = topo.getData();

            topo = topo.getNext();
            return(aux);
        }
        public String pop()
        {
            if (isEmpty())
            {
                throw new Exception();
            }
            String aux = topo.getData();

            topo = topo.getNext();
            return(aux);
        }
Example #4
0
        public TAD pop()
        {
            if (isEmpty())
            {
                throw new Exception();
            }
            TAD aux = topo.getData();

            topo = topo.getNext();
            return(aux);
        }
Example #5
0
        public int maior()
        {
            int maior;

            if (!isEmpty())
            {
                NohPilha aux = topo;
                maior = aux.getData();
                while (aux != null)
                {
                    if (maior < aux.getData())
                    {
                        maior = aux.getData();
                    }
                    aux = aux.getNext();
                }
            }
            else
            {
                throw new Exception();
            }
            return(maior);
        }
Example #6
0
        public string print()
        {
            string resultado = "";

            if (!isEmpty())
            {
                NohPilha aux = topo;
                while (aux != null)
                {
                    resultado += aux.getData() + "\r\n";
                    aux        = aux.getNext();
                }
            }
            return(resultado);
        }
Example #7
0
 public void print()
 {
     if (isEmpty())
     {
         Console.WriteLine("Pilha Vazia");
     }
     else
     {
         Console.WriteLine("Status Atual da Pilha");
         NohPilha aux = topo;
         while (aux != null)
         {
             Console.WriteLine(aux.getData());
             aux = aux.getNext();
         }
     }
 }
Example #8
0
        public string inversePrint()
        {
            List <int> resultados = new List <int>();
            string     resultado  = "";
            NohPilha   aux        = topo;

            while (aux != null)
            {
                resultados.Add(aux.getData());
                aux = aux.getNext();
            }
            resultados.Reverse();
            for (int i = 0; i < resultados.Count; i++)
            {
                resultado += resultados[i] + "\r\n";
            }
            return(resultado);
        }
Example #9
0
        public int indexOf(int button)
        {
            int resultado = -1;
            int a         = 0;

            if (!isEmpty())
            {
                NohPilha aux = topo;
                while (aux != null)
                {
                    if (aux.getData() == button)
                    {
                        resultado = a;
                    }

                    aux = aux.getNext();
                    a++;
                }
            }
            return(resultado);
        }