public void invertirlista() { ClaseBase t = inicio; ClaseBase temp = null, vali = null; while (t != null) { temp = t.Siguiente; t.Siguiente = vali; vali = t; t = temp; } inicio = vali; }
/// <summary> /// Nueva funcion de listas enlazadas /// </summary> /// <param name="dato"></param> /// <returns></returns> public int buscar(int dato) { ClaseBase temp = inicio; while (temp.Siguiente != null) { if (temp.Dato == dato) { return(temp.Dato); } temp = temp.Siguiente; } return(0); }
/// <summary> /// nueva funcion de listas enlazadas /// </summary> /// <param name="numero"></param> public void Elimi(int numero) { bool sup = true; ClaseBase temp = inicio; while (sup) { if (temp.Dato == numero) { if (temp.Siguiente != null && temp.Anterior != null) { temp.Anterior.Siguiente = temp.Siguiente; temp.Siguiente.Anterior = temp.Anterior; break; } else if (temp.Anterior != null) { temp.Anterior.Siguiente = null; break; } else if (temp.Siguiente != null) { inicio = inicio.Siguiente; break; } else { inicio = null; break; } } else if (temp.Siguiente == null) { sup = false; } temp = temp.Siguiente; } }