public void eliminar(string entrada)
        {
            Nodon actual, anterior;
            bool  encontrado;

            //inicializa los apuntadores
            actual     = primero;
            anterior   = null;
            encontrado = false;
            //busqueda del nodo anterior
            while ((actual != null) && (encontrado))
            {
                encontrado = (actual.dato.Equals(entrada));
                if (!encontrado)
                {
                    anterior = actual;
                    actual   = actual.enlace;
                }
            }
            //enlace del nodo anterior con el siguiente
            if (actual != null)
            {
                if (actual == primero)
                {
                    primero = actual.enlace;
                }
                else
                {
                    anterior.enlace = actual.enlace;
                }
                actual = null;
            }
        }
        public Lista insertarLista(string testigo, string entrada)
        {
            Nodon nuevo, anterior;

            anterior = buscarLista(testigo);
            if (anterior != null)
            {
                nuevo           = new Nodon(entrada);
                nuevo.enlace    = anterior.enlace;
                anterior.enlace = nuevo;
            }
            return(this);
        }
Example #3
0
 public void setEnlace(Nodon Enlace)
 {
     this.enlace = Enlace;
 }
Example #4
0
 public Nodon(string x, Nodon n)
 {
     dato   = x;
     enlace = n;
 }
Example #5
0
 public Nodon(string x)
 {
     dato   = x;
     enlace = null;
 }
 public Lista()
 {
     primero = null;
 }
 public Lista insertarCabeza(Nodon cabeza, string valor)
 {
     cabeza.enlace = new Nodon(valor);
     cabeza        = cabeza.enlace;
     return(this);
 }
 public Lista insertarUltimo(Nodon ultimo, string entrada)
 {
     ultimo.enlace = new Nodon(entrada);
     ultimo        = ultimo.enlace;
     return(this);
 }