Example #1
0
        public void Inserir(int Valor)
        {
            Elemento Elemento = new Elemento();

            Elemento.Numero = Valor;

            if (Inicio == null)
            {
                Inicio = Elemento;
                Fim    = Elemento;

                Elemento.Proximo = null;
            }
            else
            {
                Fim.Proximo = Elemento;
                Fim         = Elemento;
                Fim.Proximo = null;
            }
        }
Example #2
0
        public void ConcatenarListas(Lista lista1, Lista lista2)
        {
            Elemento auxLista1 = lista1.Inicio;
            Elemento auxLista2 = lista2.Inicio;

            while (auxLista1 != null || auxLista2 != null)
            {
                if (auxLista1 != null && (auxLista2 == null || auxLista1.Numero <= auxLista2.Numero))
                {
                    Inserir(auxLista1.Numero);
                    auxLista1 = auxLista1.Proximo;
                }

                if (auxLista2 != null && (auxLista1 == null || auxLista2.Numero <= auxLista1.Numero))
                {
                    Inserir(auxLista2.Numero);
                    auxLista2 = auxLista2.Proximo;
                }
            }
        }
Example #3
0
 public Lista()
 {
     Inicio = null;
     Fim    = null;
 }
Example #4
0
 public Elemento()
 {
     Numero  = 0;
     Proximo = null;
 }