示例#1
0
        public void invertirLista()
        {
            ClaseBase prev    = null;
            ClaseBase current = inicio;
            ClaseBase next;

            while (current != null)
            {
                next = current.Siguiente;
                current.Siguiente = prev;
                prev    = current.Siguiente;
                current = next;
            }

            inicio = prev;
        }
示例#2
0
        public void agregar(ClaseBase nuevo)
        {
            if (inicio == null)
            {
                inicio = nuevo;
            }
            else
            {
                ClaseBase temp = inicio;

                while (temp.Siguiente != null)
                {
                    temp = temp.Siguiente;
                }

                temp.Siguiente = nuevo;
                ultimo         = temp.Siguiente;
            }
        }
示例#3
0
        public void eliminarUltimo()
        {
            ClaseBase temp = inicio;

            if (temp.Siguiente == null)
            {
                temp = null;
            }

            while (temp.Siguiente != null)
            {
                temp = temp.Siguiente;

                if (temp.Siguiente.Siguiente == null)
                {
                    break;
                }
            }

            ultimo           = temp.Siguiente;
            ultimo.Siguiente = null;
        }
示例#4
0
        public void eliminarPorContacto(int num)
        {
            ClaseBase temp = inicio;

            while (temp.Siguiente != null)
            {
                temp = temp.Siguiente;

                if (temp.Siguiente.Contacto == num)
                {
                    temp.Siguiente = temp.Siguiente.Siguiente;
                }
            }
            if (inicio.Contacto == num)
            {
                eliminarPrimero();
            }
            else if (ultimo.Contacto == num)
            {
                eliminarUltimo();
            }
        }
示例#5
0
 public void eliminarPrimero()
 {
     inicio = inicio.Siguiente;
 }