Beispiel #1
0
        static public Lista_Enlazad Eliminar(NodoLista Lista, string nombre)
        {
            Lista_Enlazad Aux = new Lista_Enlazad();

            if (Lista.Nombre == nombre)
            {
                Aux.InsertarALaCabeza(Lista.SiguienteNodo);
                return(Aux);
            }
            else
            {
                while (Lista.SiguienteNodo != null)
                {
                    if (Lista.Nombre == nombre)
                    {
                        Aux.InsertarALaCabeza(Lista.SiguienteNodo);
                    }

                    Aux.InsertarALaCabeza(Lista);
                    Lista = Lista.SiguienteNodo;
                }
            }

            return(Aux);
        }
Beispiel #2
0
        static public void Mostrar(Lista_Enlazad lista)
        {
            Console.Clear();
            Console.Title = "Mostrar Lista";

            NodoLista aux  = lista.cabeza;
            int       cont = 1;

            //Ciclo para imprimir hasta que el sig apuntador sea null
            while (aux != null)
            {
                Console.WriteLine($"{cont}.- {aux.Nombre}");
                cont++;
                //Se cambia auxiliar por el apuntador del siguiente
                aux = aux.SiguienteNodo;
            }

            //Imprimir null en caso de que el apuntador sea null
            if (aux == null)
            {
                Console.WriteLine("No hay más arboles");
            }

            aux = null;

            Console.WriteLine();
        }
Beispiel #3
0
        static public bool Existe(Lista_Enlazad lista, string nombre)
        {
            //Error lista
            aux = lista.cabeza;
            bool existe = false;

            //Ciclo para hacer recorrido
            while (aux != null)
            {
                if (aux.Nombre == nombre)
                {
                    existe = true;
                }

                aux = aux.SiguienteNodo;
            }

            if (!existe)
            {
                Console.Clear();
                Console.Beep();
                Console.WriteLine("El arbol no existe dentro de la lista");
                System.Threading.Thread.Sleep(2000);
            }

            return(existe);
        }
Beispiel #4
0
 static public bool Verifica_Vacia(Lista_Enlazad list)
 {
     if (list.cabeza == null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #5
0
        static public int ContarElementos(Lista_Enlazad lista)
        {
            Lista_Enlazad aux      = lista;
            int           contador = 1;

            while (aux != null)
            {
                aux.cabeza = aux.cabeza.SiguienteNodo;
                contador  -= -1;
            }

            Console.WriteLine($"Tiene {contador} elementos en la lista");

            return(contador);
        }
Beispiel #6
0
        static public NodoArbol Solicitar(Lista_Enlazad lista, string nombre)
        {
            aux = lista.cabeza;

            while (aux != null)
            {
                if (aux.Nombre == nombre)
                {
                    nodoAux = aux.Arbol;
                }

                aux = aux.SiguienteNodo;
            }

            return(nodoAux);
        }
Beispiel #7
0
 static public void Vaciar(ref Lista_Enlazad lista)
 {
     lista = null;
 }